xref: /aosp_15_r20/external/llvm/test/Transforms/InstCombine/2008-07-13-DivZero.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -instcombine -S | grep "lshr.*3"
2*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -instcombine -S | grep "call .*%cond"
3*9880d681SAndroid Build Coastguard Worker; PR2506
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker; We can simplify the operand of udiv to '8', but not the operand to the
6*9880d681SAndroid Build Coastguard Worker; call.  If the callee never returns, we can't assume the div is reachable.
7*9880d681SAndroid Build Coastguard Workerdefine i32 @a(i32 %x, i32 %y) {
8*9880d681SAndroid Build Coastguard Workerentry:
9*9880d681SAndroid Build Coastguard Worker        %tobool = icmp ne i32 %y, 0             ; <i1> [#uses=1]
10*9880d681SAndroid Build Coastguard Worker        %cond = select i1 %tobool, i32 8, i32 0         ; <i32> [#uses=2]
11*9880d681SAndroid Build Coastguard Worker        %call = call i32 @b( i32 %cond )                ; <i32> [#uses=0]
12*9880d681SAndroid Build Coastguard Worker        %div = udiv i32 %x, %cond               ; <i32> [#uses=1]
13*9880d681SAndroid Build Coastguard Worker        ret i32 %div
14*9880d681SAndroid Build Coastguard Worker}
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerdeclare i32 @b(i32)
17