xref: /aosp_15_r20/external/llvm/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test merging of blocks that only have PHI nodes in them.  This tests the case
2*9880d681SAndroid Build Coastguard Worker; where the mergedinto block doesn't have any PHI nodes, and is in fact
3*9880d681SAndroid Build Coastguard Worker; dominated by the block-to-be-eliminated
4*9880d681SAndroid Build Coastguard Worker;
5*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -simplifycfg -S | not grep N:
6*9880d681SAndroid Build Coastguard Worker;
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workerdeclare i1 @foo()
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdefine i32 @test(i1 %a, i1 %b) {
11*9880d681SAndroid Build Coastguard Worker        %c = call i1 @foo()
12*9880d681SAndroid Build Coastguard Worker	br i1 %c, label %N, label %P
13*9880d681SAndroid Build Coastguard WorkerP:
14*9880d681SAndroid Build Coastguard Worker        %d = call i1 @foo()
15*9880d681SAndroid Build Coastguard Worker	br i1 %d, label %N, label %Q
16*9880d681SAndroid Build Coastguard WorkerQ:
17*9880d681SAndroid Build Coastguard Worker	br label %N
18*9880d681SAndroid Build Coastguard WorkerN:
19*9880d681SAndroid Build Coastguard Worker	%W = phi i32 [0, %0], [1, %Q], [2, %P]
20*9880d681SAndroid Build Coastguard Worker	; This block should be foldable into M
21*9880d681SAndroid Build Coastguard Worker	br label %M
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard WorkerM:
24*9880d681SAndroid Build Coastguard Worker	%R = add i32 %W, 1
25*9880d681SAndroid Build Coastguard Worker	ret i32 %R
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28