xref: /aosp_15_r20/external/llvm/test/Transforms/LCSSA/unused-phis.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -lcssa -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -passes=lcssa -S | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker; CHECK: exit1:
4*9880d681SAndroid Build Coastguard Worker; CHECK: .lcssa =
5*9880d681SAndroid Build Coastguard Worker; CHECK: exit2:
6*9880d681SAndroid Build Coastguard Worker; CHECK: .lcssa1 =
7*9880d681SAndroid Build Coastguard Worker; CHECK: exit3:
8*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: .lcssa
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Worker; Test to ensure that when there are multiple exit blocks, PHI nodes are
11*9880d681SAndroid Build Coastguard Worker; only inserted by LCSSA when there is a use dominated by a given exit
12*9880d681SAndroid Build Coastguard Worker; block.
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdeclare void @printf(i32 %i)
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerdefine i32 @unused_phis() nounwind {
17*9880d681SAndroid Build Coastguard Workerentry:
18*9880d681SAndroid Build Coastguard Worker  br label %loop
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workerloop:
21*9880d681SAndroid Build Coastguard Worker  %i = phi i32 [0, %entry], [1, %then2]
22*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %exit1, label %then1
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workerthen1:
25*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %exit2, label %then2
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerthen2:
28*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %exit3, label %loop
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Workerexit1:
31*9880d681SAndroid Build Coastguard Worker  call void @printf(i32 %i)
32*9880d681SAndroid Build Coastguard Worker  ret i32 %i
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Workerexit2:
35*9880d681SAndroid Build Coastguard Worker  ret i32 %i
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Workerexit3:
38*9880d681SAndroid Build Coastguard Worker  ret i32 0
39*9880d681SAndroid Build Coastguard Worker}
40