xref: /aosp_15_r20/external/llvm/test/Transforms/LICM/2003-02-27-PreheaderProblem.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Here we have a case where there are two loops and LICM is hoisting an
2*9880d681SAndroid Build Coastguard Worker; instruction from one loop into the other loop!  This is obviously bad and
3*9880d681SAndroid Build Coastguard Worker; happens because preheader insertion doesn't insert a preheader for this
4*9880d681SAndroid Build Coastguard Worker; case... bad.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -licm -loop-deletion -simplifycfg -S | \
7*9880d681SAndroid Build Coastguard Worker; RUN:   not grep "br "
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine i32 @main(i32 %argc) {
10*9880d681SAndroid Build Coastguard Worker; <label>:0
11*9880d681SAndroid Build Coastguard Worker	br label %bb5
12*9880d681SAndroid Build Coastguard Workerbb5:		; preds = %bb5, %0
13*9880d681SAndroid Build Coastguard Worker	%I = phi i32 [ 0, %0 ], [ %I2, %bb5 ]		; <i32> [#uses=1]
14*9880d681SAndroid Build Coastguard Worker	%I2 = add i32 %I, 1		; <i32> [#uses=2]
15*9880d681SAndroid Build Coastguard Worker	%c = icmp eq i32 %I2, 10		; <i1> [#uses=1]
16*9880d681SAndroid Build Coastguard Worker	br i1 %c, label %bb5, label %bb8
17*9880d681SAndroid Build Coastguard Workerbb8:		; preds = %bb8, %bb5
18*9880d681SAndroid Build Coastguard Worker	%cann-indvar = phi i32 [ 0, %bb8 ], [ 0, %bb5 ]		; <i32> [#uses=0]
19*9880d681SAndroid Build Coastguard Worker	%X = add i32 %argc, %argc		; <i32> [#uses=1]
20*9880d681SAndroid Build Coastguard Worker	br i1 false, label %bb8, label %bb10
21*9880d681SAndroid Build Coastguard Workerbb10:		; preds = %bb8
22*9880d681SAndroid Build Coastguard Worker	ret i32 %X
23*9880d681SAndroid Build Coastguard Worker}
24*9880d681SAndroid Build Coastguard Worker
25