1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=14 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=14 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
4; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM
5; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM
6
7; FIXME: CGSCC is not looking at callees and calleers even though it could be allowed.
8
9define i32 @test0(i32* %p) {
10; CHECK: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
11; CHECK-LABEL: define {{[^@]+}}@test0
12; CHECK-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR0:[0-9]+]] {
13; CHECK-NEXT:    [[A:%.*]] = load i32, i32* [[P]], align 4, !range [[RNG0:![0-9]+]]
14; CHECK-NEXT:    ret i32 [[A]]
15;
16  %a = load i32, i32* %p, !range !0
17  ret i32 %a
18}
19
20define i32 @test0-range-check(i32* %p) {
21; IS__TUNIT____: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
22; IS__TUNIT____-LABEL: define {{[^@]+}}@test0-range-check
23; IS__TUNIT____-SAME: (i32* nocapture nofree readonly align 4 [[P:%.*]]) #[[ATTR0]] {
24; IS__TUNIT____-NEXT:    [[A:%.*]] = tail call i32 @test0(i32* nocapture nofree readonly align 4 [[P]]) #[[ATTR3:[0-9]+]], !range [[RNG0]]
25; IS__TUNIT____-NEXT:    ret i32 [[A]]
26;
27; IS__CGSCC____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
28; IS__CGSCC____-LABEL: define {{[^@]+}}@test0-range-check
29; IS__CGSCC____-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR1:[0-9]+]] {
30; IS__CGSCC____-NEXT:    [[A:%.*]] = tail call i32 @test0(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P]]) #[[ATTR5:[0-9]+]]
31; IS__CGSCC____-NEXT:    ret i32 [[A]]
32;
33  %a = tail call i32 @test0(i32* %p)
34  ret i32 %a
35}
36
37declare void @use3-dummy(i1, i1, i1)
38define void @use3(i1, i1, i1) {
39; CHECK-LABEL: define {{[^@]+}}@use3
40; CHECK-SAME: (i1 [[TMP0:%.*]], i1 [[TMP1:%.*]], i1 [[TMP2:%.*]]) {
41; CHECK-NEXT:    tail call void @use3-dummy(i1 [[TMP0]], i1 [[TMP1]], i1 [[TMP2]])
42; CHECK-NEXT:    ret void
43;
44  tail call void @use3-dummy(i1 %0, i1 %1, i1 %2)
45  ret void
46}
47
48; TEST0 icmp test
49define void @test0-icmp-check(i32* %p){
50  ; ret = [0, 10)
51; IS__TUNIT____-LABEL: define {{[^@]+}}@test0-icmp-check
52; IS__TUNIT____-SAME: (i32* nocapture nofree readonly align 4 [[P:%.*]]) {
53; IS__TUNIT____-NEXT:    [[RET:%.*]] = tail call i32 @test0(i32* nocapture nofree readonly align 4 [[P]]) #[[ATTR3]], !range [[RNG0]]
54; IS__TUNIT____-NEXT:    [[CMP_EQ_1:%.*]] = icmp eq i32 [[RET]], 10
55; IS__TUNIT____-NEXT:    [[CMP_EQ_2:%.*]] = icmp eq i32 [[RET]], 9
56; IS__TUNIT____-NEXT:    [[CMP_EQ_3:%.*]] = icmp eq i32 [[RET]], 8
57; IS__TUNIT____-NEXT:    [[CMP_EQ_4:%.*]] = icmp eq i32 [[RET]], 1
58; IS__TUNIT____-NEXT:    [[CMP_EQ_5:%.*]] = icmp eq i32 [[RET]], 0
59; IS__TUNIT____-NEXT:    [[CMP_EQ_6:%.*]] = icmp eq i32 [[RET]], -1
60; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_EQ_1]], i1 [[CMP_EQ_2]], i1 [[CMP_EQ_3]])
61; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_EQ_4]], i1 [[CMP_EQ_5]], i1 [[CMP_EQ_6]])
62; IS__TUNIT____-NEXT:    [[CMP_NE_1:%.*]] = icmp ne i32 [[RET]], 10
63; IS__TUNIT____-NEXT:    [[CMP_NE_2:%.*]] = icmp ne i32 [[RET]], 9
64; IS__TUNIT____-NEXT:    [[CMP_NE_3:%.*]] = icmp ne i32 [[RET]], 8
65; IS__TUNIT____-NEXT:    [[CMP_NE_4:%.*]] = icmp ne i32 [[RET]], 1
66; IS__TUNIT____-NEXT:    [[CMP_NE_5:%.*]] = icmp ne i32 [[RET]], 0
67; IS__TUNIT____-NEXT:    [[CMP_NE_6:%.*]] = icmp ne i32 [[RET]], -1
68; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_NE_1]], i1 [[CMP_NE_2]], i1 [[CMP_NE_3]])
69; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_NE_4]], i1 [[CMP_NE_5]], i1 [[CMP_NE_6]])
70; IS__TUNIT____-NEXT:    [[CMP_UGT_1:%.*]] = icmp ugt i32 [[RET]], 10
71; IS__TUNIT____-NEXT:    [[CMP_UGT_2:%.*]] = icmp ugt i32 [[RET]], 9
72; IS__TUNIT____-NEXT:    [[CMP_UGT_3:%.*]] = icmp ugt i32 [[RET]], 8
73; IS__TUNIT____-NEXT:    [[CMP_UGT_4:%.*]] = icmp ugt i32 [[RET]], 1
74; IS__TUNIT____-NEXT:    [[CMP_UGT_5:%.*]] = icmp ugt i32 [[RET]], 0
75; IS__TUNIT____-NEXT:    [[CMP_UGT_6:%.*]] = icmp ugt i32 [[RET]], -1
76; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_UGT_1]], i1 [[CMP_UGT_2]], i1 [[CMP_UGT_3]])
77; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_UGT_4]], i1 [[CMP_UGT_5]], i1 [[CMP_UGT_6]])
78; IS__TUNIT____-NEXT:    [[CMP_UGE_1:%.*]] = icmp uge i32 [[RET]], 10
79; IS__TUNIT____-NEXT:    [[CMP_UGE_2:%.*]] = icmp uge i32 [[RET]], 9
80; IS__TUNIT____-NEXT:    [[CMP_UGE_3:%.*]] = icmp uge i32 [[RET]], 8
81; IS__TUNIT____-NEXT:    [[CMP_UGE_4:%.*]] = icmp uge i32 [[RET]], 1
82; IS__TUNIT____-NEXT:    [[CMP_UGE_5:%.*]] = icmp uge i32 [[RET]], 0
83; IS__TUNIT____-NEXT:    [[CMP_UGE_6:%.*]] = icmp uge i32 [[RET]], -1
84; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_UGE_1]], i1 [[CMP_UGE_2]], i1 [[CMP_UGE_3]])
85; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_UGE_4]], i1 [[CMP_UGE_5]], i1 [[CMP_UGE_6]])
86; IS__TUNIT____-NEXT:    [[CMP_SGT_1:%.*]] = icmp sgt i32 [[RET]], 10
87; IS__TUNIT____-NEXT:    [[CMP_SGT_2:%.*]] = icmp sgt i32 [[RET]], 9
88; IS__TUNIT____-NEXT:    [[CMP_SGT_3:%.*]] = icmp sgt i32 [[RET]], 8
89; IS__TUNIT____-NEXT:    [[CMP_SGT_4:%.*]] = icmp sgt i32 [[RET]], 1
90; IS__TUNIT____-NEXT:    [[CMP_SGT_5:%.*]] = icmp sgt i32 [[RET]], 0
91; IS__TUNIT____-NEXT:    [[CMP_SGT_6:%.*]] = icmp sgt i32 [[RET]], -1
92; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_SGT_1]], i1 [[CMP_SGT_2]], i1 [[CMP_SGT_3]])
93; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_SGT_4]], i1 [[CMP_SGT_5]], i1 [[CMP_SGT_6]])
94; IS__TUNIT____-NEXT:    [[CMP_GTE_1:%.*]] = icmp sge i32 [[RET]], 10
95; IS__TUNIT____-NEXT:    [[CMP_GTE_2:%.*]] = icmp sge i32 [[RET]], 9
96; IS__TUNIT____-NEXT:    [[CMP_GTE_3:%.*]] = icmp sge i32 [[RET]], 8
97; IS__TUNIT____-NEXT:    [[CMP_GTE_4:%.*]] = icmp sge i32 [[RET]], 1
98; IS__TUNIT____-NEXT:    [[CMP_GTE_5:%.*]] = icmp sge i32 [[RET]], 0
99; IS__TUNIT____-NEXT:    [[CMP_GTE_6:%.*]] = icmp sge i32 [[RET]], -1
100; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_GTE_1]], i1 [[CMP_GTE_2]], i1 [[CMP_GTE_3]])
101; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_GTE_4]], i1 [[CMP_GTE_5]], i1 [[CMP_GTE_6]])
102; IS__TUNIT____-NEXT:    [[CMP_SLT_1:%.*]] = icmp slt i32 [[RET]], 10
103; IS__TUNIT____-NEXT:    [[CMP_SLT_2:%.*]] = icmp slt i32 [[RET]], 9
104; IS__TUNIT____-NEXT:    [[CMP_SLT_3:%.*]] = icmp slt i32 [[RET]], 8
105; IS__TUNIT____-NEXT:    [[CMP_SLT_4:%.*]] = icmp slt i32 [[RET]], 1
106; IS__TUNIT____-NEXT:    [[CMP_SLT_5:%.*]] = icmp slt i32 [[RET]], 0
107; IS__TUNIT____-NEXT:    [[CMP_SLT_6:%.*]] = icmp slt i32 [[RET]], -1
108; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_SLT_1]], i1 [[CMP_SLT_2]], i1 [[CMP_SLT_3]])
109; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_SLT_4]], i1 [[CMP_SLT_5]], i1 [[CMP_SLT_6]])
110; IS__TUNIT____-NEXT:    [[CMP_LTE_1:%.*]] = icmp sle i32 [[RET]], 10
111; IS__TUNIT____-NEXT:    [[CMP_LTE_2:%.*]] = icmp sle i32 [[RET]], 9
112; IS__TUNIT____-NEXT:    [[CMP_LTE_3:%.*]] = icmp sle i32 [[RET]], 8
113; IS__TUNIT____-NEXT:    [[CMP_LTE_4:%.*]] = icmp sle i32 [[RET]], 1
114; IS__TUNIT____-NEXT:    [[CMP_LTE_5:%.*]] = icmp sle i32 [[RET]], 0
115; IS__TUNIT____-NEXT:    [[CMP_LTE_6:%.*]] = icmp sle i32 [[RET]], -1
116; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_LTE_1]], i1 [[CMP_LTE_2]], i1 [[CMP_LTE_3]])
117; IS__TUNIT____-NEXT:    tail call void @use3(i1 [[CMP_LTE_4]], i1 [[CMP_LTE_5]], i1 [[CMP_LTE_6]])
118; IS__TUNIT____-NEXT:    ret void
119;
120; IS__CGSCC____-LABEL: define {{[^@]+}}@test0-icmp-check
121; IS__CGSCC____-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) {
122; IS__CGSCC____-NEXT:    [[RET:%.*]] = tail call i32 @test0(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P]]) #[[ATTR5]]
123; IS__CGSCC____-NEXT:    [[CMP_EQ_1:%.*]] = icmp eq i32 [[RET]], 10
124; IS__CGSCC____-NEXT:    [[CMP_EQ_2:%.*]] = icmp eq i32 [[RET]], 9
125; IS__CGSCC____-NEXT:    [[CMP_EQ_3:%.*]] = icmp eq i32 [[RET]], 8
126; IS__CGSCC____-NEXT:    [[CMP_EQ_4:%.*]] = icmp eq i32 [[RET]], 1
127; IS__CGSCC____-NEXT:    [[CMP_EQ_5:%.*]] = icmp eq i32 [[RET]], 0
128; IS__CGSCC____-NEXT:    [[CMP_EQ_6:%.*]] = icmp eq i32 [[RET]], -1
129; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_EQ_1]], i1 [[CMP_EQ_2]], i1 [[CMP_EQ_3]])
130; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_EQ_4]], i1 [[CMP_EQ_5]], i1 [[CMP_EQ_6]])
131; IS__CGSCC____-NEXT:    [[CMP_NE_1:%.*]] = icmp ne i32 [[RET]], 10
132; IS__CGSCC____-NEXT:    [[CMP_NE_2:%.*]] = icmp ne i32 [[RET]], 9
133; IS__CGSCC____-NEXT:    [[CMP_NE_3:%.*]] = icmp ne i32 [[RET]], 8
134; IS__CGSCC____-NEXT:    [[CMP_NE_4:%.*]] = icmp ne i32 [[RET]], 1
135; IS__CGSCC____-NEXT:    [[CMP_NE_5:%.*]] = icmp ne i32 [[RET]], 0
136; IS__CGSCC____-NEXT:    [[CMP_NE_6:%.*]] = icmp ne i32 [[RET]], -1
137; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_NE_1]], i1 [[CMP_NE_2]], i1 [[CMP_NE_3]])
138; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_NE_4]], i1 [[CMP_NE_5]], i1 [[CMP_NE_6]])
139; IS__CGSCC____-NEXT:    [[CMP_UGT_1:%.*]] = icmp ugt i32 [[RET]], 10
140; IS__CGSCC____-NEXT:    [[CMP_UGT_2:%.*]] = icmp ugt i32 [[RET]], 9
141; IS__CGSCC____-NEXT:    [[CMP_UGT_3:%.*]] = icmp ugt i32 [[RET]], 8
142; IS__CGSCC____-NEXT:    [[CMP_UGT_4:%.*]] = icmp ugt i32 [[RET]], 1
143; IS__CGSCC____-NEXT:    [[CMP_UGT_5:%.*]] = icmp ugt i32 [[RET]], 0
144; IS__CGSCC____-NEXT:    [[CMP_UGT_6:%.*]] = icmp ugt i32 [[RET]], -1
145; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_UGT_1]], i1 [[CMP_UGT_2]], i1 [[CMP_UGT_3]])
146; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_UGT_4]], i1 [[CMP_UGT_5]], i1 [[CMP_UGT_6]])
147; IS__CGSCC____-NEXT:    [[CMP_UGE_1:%.*]] = icmp uge i32 [[RET]], 10
148; IS__CGSCC____-NEXT:    [[CMP_UGE_2:%.*]] = icmp uge i32 [[RET]], 9
149; IS__CGSCC____-NEXT:    [[CMP_UGE_3:%.*]] = icmp uge i32 [[RET]], 8
150; IS__CGSCC____-NEXT:    [[CMP_UGE_4:%.*]] = icmp uge i32 [[RET]], 1
151; IS__CGSCC____-NEXT:    [[CMP_UGE_5:%.*]] = icmp uge i32 [[RET]], 0
152; IS__CGSCC____-NEXT:    [[CMP_UGE_6:%.*]] = icmp uge i32 [[RET]], -1
153; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_UGE_1]], i1 [[CMP_UGE_2]], i1 [[CMP_UGE_3]])
154; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_UGE_4]], i1 [[CMP_UGE_5]], i1 [[CMP_UGE_6]])
155; IS__CGSCC____-NEXT:    [[CMP_SGT_1:%.*]] = icmp sgt i32 [[RET]], 10
156; IS__CGSCC____-NEXT:    [[CMP_SGT_2:%.*]] = icmp sgt i32 [[RET]], 9
157; IS__CGSCC____-NEXT:    [[CMP_SGT_3:%.*]] = icmp sgt i32 [[RET]], 8
158; IS__CGSCC____-NEXT:    [[CMP_SGT_4:%.*]] = icmp sgt i32 [[RET]], 1
159; IS__CGSCC____-NEXT:    [[CMP_SGT_5:%.*]] = icmp sgt i32 [[RET]], 0
160; IS__CGSCC____-NEXT:    [[CMP_SGT_6:%.*]] = icmp sgt i32 [[RET]], -1
161; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_SGT_1]], i1 [[CMP_SGT_2]], i1 [[CMP_SGT_3]])
162; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_SGT_4]], i1 [[CMP_SGT_5]], i1 [[CMP_SGT_6]])
163; IS__CGSCC____-NEXT:    [[CMP_GTE_1:%.*]] = icmp sge i32 [[RET]], 10
164; IS__CGSCC____-NEXT:    [[CMP_GTE_2:%.*]] = icmp sge i32 [[RET]], 9
165; IS__CGSCC____-NEXT:    [[CMP_GTE_3:%.*]] = icmp sge i32 [[RET]], 8
166; IS__CGSCC____-NEXT:    [[CMP_GTE_4:%.*]] = icmp sge i32 [[RET]], 1
167; IS__CGSCC____-NEXT:    [[CMP_GTE_5:%.*]] = icmp sge i32 [[RET]], 0
168; IS__CGSCC____-NEXT:    [[CMP_GTE_6:%.*]] = icmp sge i32 [[RET]], -1
169; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_GTE_1]], i1 [[CMP_GTE_2]], i1 [[CMP_GTE_3]])
170; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_GTE_4]], i1 [[CMP_GTE_5]], i1 [[CMP_GTE_6]])
171; IS__CGSCC____-NEXT:    [[CMP_SLT_1:%.*]] = icmp slt i32 [[RET]], 10
172; IS__CGSCC____-NEXT:    [[CMP_SLT_2:%.*]] = icmp slt i32 [[RET]], 9
173; IS__CGSCC____-NEXT:    [[CMP_SLT_3:%.*]] = icmp slt i32 [[RET]], 8
174; IS__CGSCC____-NEXT:    [[CMP_SLT_4:%.*]] = icmp slt i32 [[RET]], 1
175; IS__CGSCC____-NEXT:    [[CMP_SLT_5:%.*]] = icmp slt i32 [[RET]], 0
176; IS__CGSCC____-NEXT:    [[CMP_SLT_6:%.*]] = icmp slt i32 [[RET]], -1
177; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_SLT_1]], i1 [[CMP_SLT_2]], i1 [[CMP_SLT_3]])
178; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_SLT_4]], i1 [[CMP_SLT_5]], i1 [[CMP_SLT_6]])
179; IS__CGSCC____-NEXT:    [[CMP_LTE_1:%.*]] = icmp sle i32 [[RET]], 10
180; IS__CGSCC____-NEXT:    [[CMP_LTE_2:%.*]] = icmp sle i32 [[RET]], 9
181; IS__CGSCC____-NEXT:    [[CMP_LTE_3:%.*]] = icmp sle i32 [[RET]], 8
182; IS__CGSCC____-NEXT:    [[CMP_LTE_4:%.*]] = icmp sle i32 [[RET]], 1
183; IS__CGSCC____-NEXT:    [[CMP_LTE_5:%.*]] = icmp sle i32 [[RET]], 0
184; IS__CGSCC____-NEXT:    [[CMP_LTE_6:%.*]] = icmp sle i32 [[RET]], -1
185; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_LTE_1]], i1 [[CMP_LTE_2]], i1 [[CMP_LTE_3]])
186; IS__CGSCC____-NEXT:    tail call void @use3(i1 [[CMP_LTE_4]], i1 [[CMP_LTE_5]], i1 [[CMP_LTE_6]])
187; IS__CGSCC____-NEXT:    ret void
188;
189  %ret = tail call i32 @test0(i32 *%p)
190
191  ; ret = [0, 10), eq
192  %cmp-eq-1 = icmp eq i32 %ret, 10
193  %cmp-eq-2 = icmp eq i32 %ret, 9
194  %cmp-eq-3 = icmp eq i32 %ret, 8
195  %cmp-eq-4 = icmp eq i32 %ret, 1
196  %cmp-eq-5 = icmp eq i32 %ret, 0
197  %cmp-eq-6 = icmp eq i32 %ret, -1
198  tail call void @use3(i1 %cmp-eq-1, i1 %cmp-eq-2, i1 %cmp-eq-3)
199  tail call void @use3(i1 %cmp-eq-4, i1 %cmp-eq-5, i1 %cmp-eq-6)
200
201  ; ret = [0, 10), ne
202  %cmp-ne-1 = icmp ne i32 %ret, 10
203  %cmp-ne-2 = icmp ne i32 %ret, 9
204  %cmp-ne-3 = icmp ne i32 %ret, 8
205  %cmp-ne-4 = icmp ne i32 %ret, 1
206  %cmp-ne-5 = icmp ne i32 %ret, 0
207  %cmp-ne-6 = icmp ne i32 %ret, -1
208  tail call void @use3(i1 %cmp-ne-1, i1 %cmp-ne-2, i1 %cmp-ne-3)
209  tail call void @use3(i1 %cmp-ne-4, i1 %cmp-ne-5, i1 %cmp-ne-6)
210
211  ; ret = [0, 10), ugt
212  %cmp-ugt-1 = icmp ugt i32 %ret, 10
213  %cmp-ugt-2 = icmp ugt i32 %ret, 9
214  %cmp-ugt-3 = icmp ugt i32 %ret, 8
215  %cmp-ugt-4 = icmp ugt i32 %ret, 1
216  %cmp-ugt-5 = icmp ugt i32 %ret, 0
217  %cmp-ugt-6 = icmp ugt i32 %ret, -1
218  tail call void @use3(i1 %cmp-ugt-1, i1 %cmp-ugt-2, i1 %cmp-ugt-3)
219  tail call void @use3(i1 %cmp-ugt-4, i1 %cmp-ugt-5, i1 %cmp-ugt-6)
220
221  ; ret = [0, 10), uge
222  %cmp-uge-1 = icmp uge i32 %ret, 10
223  %cmp-uge-2 = icmp uge i32 %ret, 9
224  %cmp-uge-3 = icmp uge i32 %ret, 8
225  %cmp-uge-4 = icmp uge i32 %ret, 1
226  %cmp-uge-5 = icmp uge i32 %ret, 0
227  %cmp-uge-6 = icmp uge i32 %ret, -1
228  tail call void @use3(i1 %cmp-uge-1, i1 %cmp-uge-2, i1 %cmp-uge-3)
229  tail call void @use3(i1 %cmp-uge-4, i1 %cmp-uge-5, i1 %cmp-uge-6)
230
231  ; ret = [0, 10), sgt
232  %cmp-sgt-1 = icmp sgt i32 %ret, 10
233  %cmp-sgt-2 = icmp sgt i32 %ret, 9
234  %cmp-sgt-3 = icmp sgt i32 %ret, 8
235  %cmp-sgt-4 = icmp sgt i32 %ret, 1
236  %cmp-sgt-5 = icmp sgt i32 %ret, 0
237  %cmp-sgt-6 = icmp sgt i32 %ret, -1
238  tail call void @use3(i1 %cmp-sgt-1, i1 %cmp-sgt-2, i1 %cmp-sgt-3)
239  tail call void @use3(i1 %cmp-sgt-4, i1 %cmp-sgt-5, i1 %cmp-sgt-6)
240
241  ; ret = [0, 10), sge
242  %cmp-gte-1 = icmp sge i32 %ret, 10
243  %cmp-gte-2 = icmp sge i32 %ret, 9
244  %cmp-gte-3 = icmp sge i32 %ret, 8
245  %cmp-gte-4 = icmp sge i32 %ret, 1
246  %cmp-gte-5 = icmp sge i32 %ret, 0
247  %cmp-gte-6 = icmp sge i32 %ret, -1
248  tail call void @use3(i1 %cmp-gte-1, i1 %cmp-gte-2, i1 %cmp-gte-3)
249  tail call void @use3(i1 %cmp-gte-4, i1 %cmp-gte-5, i1 %cmp-gte-6)
250
251  ; ret = [0, 10), slt
252  %cmp-slt-1 = icmp slt i32 %ret, 10
253  %cmp-slt-2 = icmp slt i32 %ret, 9
254  %cmp-slt-3 = icmp slt i32 %ret, 8
255  %cmp-slt-4 = icmp slt i32 %ret, 1
256  %cmp-slt-5 = icmp slt i32 %ret, 0
257  %cmp-slt-6 = icmp slt i32 %ret, -1
258  tail call void @use3(i1 %cmp-slt-1, i1 %cmp-slt-2, i1 %cmp-slt-3)
259  tail call void @use3(i1 %cmp-slt-4, i1 %cmp-slt-5, i1 %cmp-slt-6)
260
261  ; ret = [0, 10), sle
262  %cmp-lte-1 = icmp sle i32 %ret, 10
263  %cmp-lte-2 = icmp sle i32 %ret, 9
264  %cmp-lte-3 = icmp sle i32 %ret, 8
265  %cmp-lte-4 = icmp sle i32 %ret, 1
266  %cmp-lte-5 = icmp sle i32 %ret, 0
267  %cmp-lte-6 = icmp sle i32 %ret, -1
268  tail call void @use3(i1 %cmp-lte-1, i1 %cmp-lte-2, i1 %cmp-lte-3)
269  tail call void @use3(i1 %cmp-lte-4, i1 %cmp-lte-5, i1 %cmp-lte-6)
270
271  ret void
272}
273define i32 @test1(i32* %p) {
274; CHECK: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
275; CHECK-LABEL: define {{[^@]+}}@test1
276; CHECK-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR0]] {
277; CHECK-NEXT:    [[LOAD_10_100:%.*]] = load i32, i32* [[P]], align 4, !range [[RNG1:![0-9]+]]
278; CHECK-NEXT:    [[ADD_10_THEN_20_110:%.*]] = add i32 [[LOAD_10_100]], 10
279; CHECK-NEXT:    [[MUL_10_THEN_200_1091:%.*]] = mul i32 [[ADD_10_THEN_20_110]], 10
280; CHECK-NEXT:    ret i32 [[MUL_10_THEN_200_1091]]
281;
282  %load-10-100 = load i32, i32* %p, !range !1
283  %add-10-then-20-110 = add i32 %load-10-100, 10
284  %mul-10-then-200-1091 = mul i32 %add-10-then-20-110, 10
285  ret i32 %mul-10-then-200-1091
286}
287
288define i1 @test1-check(i32* %p) {
289;
290; IS__TUNIT____: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
291; IS__TUNIT____-LABEL: define {{[^@]+}}@test1-check
292; IS__TUNIT____-SAME: (i32* nocapture nofree readonly align 4 [[P:%.*]]) #[[ATTR0]] {
293; IS__TUNIT____-NEXT:    [[RES:%.*]] = tail call i32 @test1(i32* nocapture nofree readonly align 4 [[P]]) #[[ATTR3]], !range [[RNG2:![0-9]+]]
294; IS__TUNIT____-NEXT:    [[CMP:%.*]] = icmp eq i32 [[RES]], 500
295; IS__TUNIT____-NEXT:    ret i1 [[CMP]]
296;
297; IS__CGSCC____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
298; IS__CGSCC____-LABEL: define {{[^@]+}}@test1-check
299; IS__CGSCC____-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR1]] {
300; IS__CGSCC____-NEXT:    [[RES:%.*]] = tail call i32 @test1(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P]]) #[[ATTR5]]
301; IS__CGSCC____-NEXT:    [[CMP:%.*]] = icmp eq i32 [[RES]], 500
302; IS__CGSCC____-NEXT:    ret i1 [[CMP]]
303;
304  %res = tail call i32 @test1(i32* %p)
305  %cmp = icmp eq i32 %res, 500
306  ret i1 %cmp
307}
308
309;  TEST2
310;  int test2(int *p) { return *p == 0 ? 4 : 3; }
311;  int test2_check(int *p) {
312;    int call = test2(p);
313;    if (call == 5) {
314;      // dead block
315;      return 2;
316;    } else {
317;      return 3;
318;    }
319;  }
320
321define i32 @test2(i32* %p) {
322; CHECK: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
323; CHECK-LABEL: define {{[^@]+}}@test2
324; CHECK-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR0]] {
325; CHECK-NEXT:  entry:
326; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* [[P]], align 4
327; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i32 [[TMP0]], 0
328; CHECK-NEXT:    [[COND:%.*]] = select i1 [[TOBOOL]], i32 4, i32 3
329; CHECK-NEXT:    ret i32 [[COND]]
330;
331entry:
332  %0 = load i32, i32* %p, align 4
333  %tobool = icmp eq i32 %0, 0
334  %cond = select i1 %tobool, i32 4, i32 3
335  ret i32 %cond
336}
337
338define i32 @test2_check(i32* %p) {
339; IS__TUNIT____: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
340; IS__TUNIT____-LABEL: define {{[^@]+}}@test2_check
341; IS__TUNIT____-SAME: (i32* nocapture nofree readonly align 4 [[P:%.*]]) #[[ATTR0]] {
342; IS__TUNIT____-NEXT:  entry:
343; IS__TUNIT____-NEXT:    [[CALL:%.*]] = tail call i32 @test2(i32* nocapture nofree readonly align 4 [[P]]) #[[ATTR3]]
344; IS__TUNIT____-NEXT:    [[CMP:%.*]] = icmp slt i32 [[CALL]], 5
345; IS__TUNIT____-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
346; IS__TUNIT____:       if.then:
347; IS__TUNIT____-NEXT:    br label [[RETURN:%.*]]
348; IS__TUNIT____:       if.end:
349; IS__TUNIT____-NEXT:    br label [[RETURN]]
350; IS__TUNIT____:       return:
351; IS__TUNIT____-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ 2, [[IF_THEN]] ], [ 3, [[IF_END]] ]
352; IS__TUNIT____-NEXT:    ret i32 [[RETVAL_0]]
353;
354; IS__CGSCC____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
355; IS__CGSCC____-LABEL: define {{[^@]+}}@test2_check
356; IS__CGSCC____-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR1]] {
357; IS__CGSCC____-NEXT:  entry:
358; IS__CGSCC____-NEXT:    [[CALL:%.*]] = tail call i32 @test2(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P]]) #[[ATTR5]]
359; IS__CGSCC____-NEXT:    [[CMP:%.*]] = icmp slt i32 [[CALL]], 5
360; IS__CGSCC____-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
361; IS__CGSCC____:       if.then:
362; IS__CGSCC____-NEXT:    br label [[RETURN:%.*]]
363; IS__CGSCC____:       if.end:
364; IS__CGSCC____-NEXT:    br label [[RETURN]]
365; IS__CGSCC____:       return:
366; IS__CGSCC____-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ 2, [[IF_THEN]] ], [ 3, [[IF_END]] ]
367; IS__CGSCC____-NEXT:    ret i32 [[RETVAL_0]]
368;
369entry:
370  %call = tail call i32 @test2(i32* %p)
371  %cmp = icmp slt i32 %call, 5
372  br i1 %cmp, label %if.then, label %if.end
373
374if.then:                                          ; preds = %entry
375  br label %return
376
377if.end:                                           ; preds = %entry
378  br label %return
379
380return:                                           ; preds = %if.end, %if.then
381  %retval.0 = phi i32 [ 2, %if.then ], [ 3, %if.end ]
382  ret i32 %retval.0
383}
384
385; TEST 3 SECV test
386
387; void unkown();
388; int r1(unsigned int u){
389;   int sum = 0;
390;   for(int i = 0; i<100;i++){
391;     sum += i;
392;   }
393;   // sum = 50 * 49 / 2
394;   if(sum > 10000){
395;   // dead block
396;     return 20;
397;   }else {
398;     return 10;
399;   }
400; }
401; void f1(int u){
402;   if(r1(u) > 15){
403;   // deadblock
404;     unkown();
405;   }else {
406;     return;
407;   }
408; }
409
410declare dso_local void @unkown()
411
412define internal i32 @r1(i32) local_unnamed_addr {
413; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone
414; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@r1
415; IS__TUNIT_OPM-SAME: () local_unnamed_addr #[[ATTR1:[0-9]+]] {
416; IS__TUNIT_OPM-NEXT:    br label [[TMP4:%.*]]
417; IS__TUNIT_OPM:       1:
418; IS__TUNIT_OPM-NEXT:    [[TMP2:%.*]] = icmp sgt i32 [[TMP7:%.*]], 10000
419; IS__TUNIT_OPM-NEXT:    br i1 [[TMP2]], label [[TMP3:%.*]], label [[F:%.*]]
420; IS__TUNIT_OPM:       3:
421; IS__TUNIT_OPM-NEXT:    ret i32 20
422; IS__TUNIT_OPM:       f:
423; IS__TUNIT_OPM-NEXT:    ret i32 10
424; IS__TUNIT_OPM:       4:
425; IS__TUNIT_OPM-NEXT:    [[TMP5:%.*]] = phi i32 [ 0, [[TMP0:%.*]] ], [ [[TMP8:%.*]], [[TMP4]] ]
426; IS__TUNIT_OPM-NEXT:    [[TMP6:%.*]] = phi i32 [ 0, [[TMP0]] ], [ [[TMP7]], [[TMP4]] ]
427; IS__TUNIT_OPM-NEXT:    [[TMP7]] = add nuw nsw i32 [[TMP5]], [[TMP6]]
428; IS__TUNIT_OPM-NEXT:    [[TMP8]] = add nuw nsw i32 [[TMP5]], 1
429; IS__TUNIT_OPM-NEXT:    [[TMP9:%.*]] = icmp eq i32 [[TMP8]], 100
430; IS__TUNIT_OPM-NEXT:    br i1 [[TMP9]], label [[TMP1:%.*]], label [[TMP4]]
431;
432; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
433; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@r1
434; IS__TUNIT_NPM-SAME: () local_unnamed_addr #[[ATTR1:[0-9]+]] {
435; IS__TUNIT_NPM-NEXT:    br label [[TMP4:%.*]]
436; IS__TUNIT_NPM:       1:
437; IS__TUNIT_NPM-NEXT:    [[TMP2:%.*]] = icmp sgt i32 [[TMP7:%.*]], 10000
438; IS__TUNIT_NPM-NEXT:    br i1 [[TMP2]], label [[TMP3:%.*]], label [[F:%.*]]
439; IS__TUNIT_NPM:       3:
440; IS__TUNIT_NPM-NEXT:    ret i32 20
441; IS__TUNIT_NPM:       f:
442; IS__TUNIT_NPM-NEXT:    ret i32 10
443; IS__TUNIT_NPM:       4:
444; IS__TUNIT_NPM-NEXT:    [[TMP5:%.*]] = phi i32 [ 0, [[TMP0:%.*]] ], [ [[TMP8:%.*]], [[TMP4]] ]
445; IS__TUNIT_NPM-NEXT:    [[TMP6:%.*]] = phi i32 [ 0, [[TMP0]] ], [ [[TMP7]], [[TMP4]] ]
446; IS__TUNIT_NPM-NEXT:    [[TMP7]] = add nuw nsw i32 [[TMP5]], [[TMP6]]
447; IS__TUNIT_NPM-NEXT:    [[TMP8]] = add nuw nsw i32 [[TMP5]], 1
448; IS__TUNIT_NPM-NEXT:    [[TMP9:%.*]] = icmp eq i32 [[TMP8]], 100
449; IS__TUNIT_NPM-NEXT:    br i1 [[TMP9]], label [[TMP1:%.*]], label [[TMP4]]
450;
451; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone
452; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@r1
453; IS__CGSCC_OPM-SAME: () local_unnamed_addr #[[ATTR2:[0-9]+]] {
454; IS__CGSCC_OPM-NEXT:    br label [[TMP4:%.*]]
455; IS__CGSCC_OPM:       1:
456; IS__CGSCC_OPM-NEXT:    [[TMP2:%.*]] = icmp sgt i32 [[TMP7:%.*]], 10000
457; IS__CGSCC_OPM-NEXT:    br i1 [[TMP2]], label [[TMP3:%.*]], label [[F:%.*]]
458; IS__CGSCC_OPM:       3:
459; IS__CGSCC_OPM-NEXT:    ret i32 20
460; IS__CGSCC_OPM:       f:
461; IS__CGSCC_OPM-NEXT:    ret i32 10
462; IS__CGSCC_OPM:       4:
463; IS__CGSCC_OPM-NEXT:    [[TMP5:%.*]] = phi i32 [ 0, [[TMP0:%.*]] ], [ [[TMP8:%.*]], [[TMP4]] ]
464; IS__CGSCC_OPM-NEXT:    [[TMP6:%.*]] = phi i32 [ 0, [[TMP0]] ], [ [[TMP7]], [[TMP4]] ]
465; IS__CGSCC_OPM-NEXT:    [[TMP7]] = add nuw nsw i32 [[TMP5]], [[TMP6]]
466; IS__CGSCC_OPM-NEXT:    [[TMP8]] = add nuw nsw i32 [[TMP5]], 1
467; IS__CGSCC_OPM-NEXT:    [[TMP9:%.*]] = icmp eq i32 [[TMP8]], 100
468; IS__CGSCC_OPM-NEXT:    br i1 [[TMP9]], label [[TMP1:%.*]], label [[TMP4]]
469;
470; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
471; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@r1
472; IS__CGSCC_NPM-SAME: () local_unnamed_addr #[[ATTR2:[0-9]+]] {
473; IS__CGSCC_NPM-NEXT:    br label [[TMP4:%.*]]
474; IS__CGSCC_NPM:       1:
475; IS__CGSCC_NPM-NEXT:    [[TMP2:%.*]] = icmp sgt i32 [[TMP7:%.*]], 10000
476; IS__CGSCC_NPM-NEXT:    br i1 [[TMP2]], label [[TMP3:%.*]], label [[F:%.*]]
477; IS__CGSCC_NPM:       3:
478; IS__CGSCC_NPM-NEXT:    ret i32 20
479; IS__CGSCC_NPM:       f:
480; IS__CGSCC_NPM-NEXT:    ret i32 10
481; IS__CGSCC_NPM:       4:
482; IS__CGSCC_NPM-NEXT:    [[TMP5:%.*]] = phi i32 [ 0, [[TMP0:%.*]] ], [ [[TMP8:%.*]], [[TMP4]] ]
483; IS__CGSCC_NPM-NEXT:    [[TMP6:%.*]] = phi i32 [ 0, [[TMP0]] ], [ [[TMP7]], [[TMP4]] ]
484; IS__CGSCC_NPM-NEXT:    [[TMP7]] = add nuw nsw i32 [[TMP5]], [[TMP6]]
485; IS__CGSCC_NPM-NEXT:    [[TMP8]] = add nuw nsw i32 [[TMP5]], 1
486; IS__CGSCC_NPM-NEXT:    [[TMP9:%.*]] = icmp eq i32 [[TMP8]], 100
487; IS__CGSCC_NPM-NEXT:    br i1 [[TMP9]], label [[TMP1:%.*]], label [[TMP4]]
488;
489  br label %5
490
4912:                                                ; preds = %5
492  %3 = icmp sgt i32 %8, 10000
493  br i1 %3, label %4, label %f
4944:
495  ret i32 20
496f:
497  ret i32 10
4985:                                                ; preds = %5, %1
499  %6 = phi i32 [ 0, %1 ], [ %9, %5 ]
500  %7 = phi i32 [ 0, %1 ], [ %8, %5 ]
501  %8 = add nuw nsw i32 %6, %7
502  %9 = add nuw nsw i32 %6, 1
503  %10 = icmp eq i32 %9, 100
504  br i1 %10, label %2, label %5
505}
506
507define void @f1(i32){
508; IS__TUNIT____-LABEL: define {{[^@]+}}@f1
509; IS__TUNIT____-SAME: (i32 [[TMP0:%.*]]) {
510; IS__TUNIT____-NEXT:    [[TMP2:%.*]] = tail call i32 @r1() #[[ATTR4:[0-9]+]]
511; IS__TUNIT____-NEXT:    [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], 15
512; IS__TUNIT____-NEXT:    br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP5:%.*]]
513; IS__TUNIT____:       4:
514; IS__TUNIT____-NEXT:    tail call void @unkown()
515; IS__TUNIT____-NEXT:    br label [[TMP5]]
516; IS__TUNIT____:       5:
517; IS__TUNIT____-NEXT:    ret void
518;
519; IS__CGSCC____-LABEL: define {{[^@]+}}@f1
520; IS__CGSCC____-SAME: (i32 [[TMP0:%.*]]) {
521; IS__CGSCC____-NEXT:    [[TMP2:%.*]] = tail call i32 @r1() #[[ATTR6:[0-9]+]]
522; IS__CGSCC____-NEXT:    [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], 15
523; IS__CGSCC____-NEXT:    br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP5:%.*]]
524; IS__CGSCC____:       4:
525; IS__CGSCC____-NEXT:    tail call void @unkown()
526; IS__CGSCC____-NEXT:    br label [[TMP5]]
527; IS__CGSCC____:       5:
528; IS__CGSCC____-NEXT:    ret void
529;
530  %2 = tail call i32 @r1(i32 %0)
531  %3 = icmp sgt i32 %2, 15
532  br i1 %3, label %4, label %5
533
5344:                                                ; preds = %1
535  tail call void @unkown()
536  br label %5
537
5385:                                                ; preds = %1, %4
539  ret void
540}
541
542; TEST4 LVI test
543
544; f1
545; int test4-f1(int u){
546;   if(u>=0) {
547;     return u;
548;   }else{
549;     return 0;
550;   }
551; }
552define dso_local i32 @test4-f1(i32 %u) {
553; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
554; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@test4-f1
555; IS__TUNIT_OPM-SAME: (i32 [[U:%.*]]) #[[ATTR2:[0-9]+]] {
556; IS__TUNIT_OPM-NEXT:  entry:
557; IS__TUNIT_OPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[U]], -1
558; IS__TUNIT_OPM-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[RETURN:%.*]]
559; IS__TUNIT_OPM:       if.then:
560; IS__TUNIT_OPM-NEXT:    br label [[RETURN]]
561; IS__TUNIT_OPM:       return:
562; IS__TUNIT_OPM-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ [[U]], [[IF_THEN]] ], [ 0, [[ENTRY:%.*]] ]
563; IS__TUNIT_OPM-NEXT:    ret i32 [[RETVAL_0]]
564;
565; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
566; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@test4-f1
567; IS__TUNIT_NPM-SAME: (i32 [[U:%.*]]) #[[ATTR1]] {
568; IS__TUNIT_NPM-NEXT:  entry:
569; IS__TUNIT_NPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[U]], -1
570; IS__TUNIT_NPM-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[RETURN:%.*]]
571; IS__TUNIT_NPM:       if.then:
572; IS__TUNIT_NPM-NEXT:    br label [[RETURN]]
573; IS__TUNIT_NPM:       return:
574; IS__TUNIT_NPM-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ [[U]], [[IF_THEN]] ], [ 0, [[ENTRY:%.*]] ]
575; IS__TUNIT_NPM-NEXT:    ret i32 [[RETVAL_0]]
576;
577; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
578; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test4-f1
579; IS__CGSCC_OPM-SAME: (i32 [[U:%.*]]) #[[ATTR3:[0-9]+]] {
580; IS__CGSCC_OPM-NEXT:  entry:
581; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[U]], -1
582; IS__CGSCC_OPM-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[RETURN:%.*]]
583; IS__CGSCC_OPM:       if.then:
584; IS__CGSCC_OPM-NEXT:    br label [[RETURN]]
585; IS__CGSCC_OPM:       return:
586; IS__CGSCC_OPM-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ [[U]], [[IF_THEN]] ], [ 0, [[ENTRY:%.*]] ]
587; IS__CGSCC_OPM-NEXT:    ret i32 [[RETVAL_0]]
588;
589; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
590; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test4-f1
591; IS__CGSCC_NPM-SAME: (i32 [[U:%.*]]) #[[ATTR2]] {
592; IS__CGSCC_NPM-NEXT:  entry:
593; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[U]], -1
594; IS__CGSCC_NPM-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[RETURN:%.*]]
595; IS__CGSCC_NPM:       if.then:
596; IS__CGSCC_NPM-NEXT:    br label [[RETURN]]
597; IS__CGSCC_NPM:       return:
598; IS__CGSCC_NPM-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ [[U]], [[IF_THEN]] ], [ 0, [[ENTRY:%.*]] ]
599; IS__CGSCC_NPM-NEXT:    ret i32 [[RETVAL_0]]
600;
601; FIXME: RETVAL_0 >= 0
602entry:
603  %cmp = icmp sgt i32 %u, -1
604  br i1 %cmp, label %if.then, label %return
605
606if.then:                                          ; preds = %entry
607  br label %return
608
609return:                                           ; preds = %entry, %if.then
610  %retval.0 = phi i32 [ %u, %if.then ], [ 0, %entry ]
611  ret i32 %retval.0
612}
613
614
615define dso_local i32 @test4-g1(i32 %u) {
616; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
617; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@test4-g1
618; IS__TUNIT_OPM-SAME: (i32 [[U:%.*]]) #[[ATTR2]] {
619; IS__TUNIT_OPM-NEXT:  entry:
620; IS__TUNIT_OPM-NEXT:    [[CALL:%.*]] = tail call i32 @test4-f1(i32 [[U]]) #[[ATTR5:[0-9]+]]
621; IS__TUNIT_OPM-NEXT:    ret i32 [[CALL]]
622;
623; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
624; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@test4-g1
625; IS__TUNIT_NPM-SAME: (i32 [[U:%.*]]) #[[ATTR1]] {
626; IS__TUNIT_NPM-NEXT:  entry:
627; IS__TUNIT_NPM-NEXT:    [[CALL:%.*]] = tail call i32 @test4-f1(i32 [[U]]) #[[ATTR4]]
628; IS__TUNIT_NPM-NEXT:    ret i32 [[CALL]]
629;
630; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
631; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test4-g1
632; IS__CGSCC_OPM-SAME: (i32 [[U:%.*]]) #[[ATTR4:[0-9]+]] {
633; IS__CGSCC_OPM-NEXT:  entry:
634; IS__CGSCC_OPM-NEXT:    [[CALL:%.*]] = tail call i32 @test4-f1(i32 [[U]]) #[[ATTR7:[0-9]+]]
635; IS__CGSCC_OPM-NEXT:    ret i32 [[CALL]]
636;
637; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
638; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test4-g1
639; IS__CGSCC_NPM-SAME: (i32 [[U:%.*]]) #[[ATTR3:[0-9]+]] {
640; IS__CGSCC_NPM-NEXT:  entry:
641; IS__CGSCC_NPM-NEXT:    [[CALL:%.*]] = tail call i32 @test4-f1(i32 [[U]]) #[[ATTR6]]
642; IS__CGSCC_NPM-NEXT:    ret i32 [[CALL]]
643;
644; FIXME: %call should have range [0, inf]
645
646entry:
647  %call = tail call i32 @test4-f1(i32 %u)
648  ret i32 %call
649}
650
651; f2
652; int test4-f1(int u){
653;   if(u>-1) {
654;     return u+1;
655;   }else{
656;     return 1;
657;   }
658; }
659define dso_local i32 @test4-f2(i32 %u) {
660; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
661; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@test4-f2
662; IS__TUNIT_OPM-SAME: (i32 [[U:%.*]]) #[[ATTR2]] {
663; IS__TUNIT_OPM-NEXT:  entry:
664; IS__TUNIT_OPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[U]], -1
665; IS__TUNIT_OPM-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
666; IS__TUNIT_OPM:       if.then:
667; IS__TUNIT_OPM-NEXT:    [[ADD:%.*]] = add nuw nsw i32 [[U]], 1
668; IS__TUNIT_OPM-NEXT:    br label [[RETURN:%.*]]
669; IS__TUNIT_OPM:       if.else:
670; IS__TUNIT_OPM-NEXT:    br label [[RETURN]]
671; IS__TUNIT_OPM:       return:
672; IS__TUNIT_OPM-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ [[ADD]], [[IF_THEN]] ], [ 1, [[IF_ELSE]] ]
673; IS__TUNIT_OPM-NEXT:    ret i32 [[RETVAL_0]]
674;
675; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
676; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@test4-f2
677; IS__TUNIT_NPM-SAME: (i32 [[U:%.*]]) #[[ATTR1]] {
678; IS__TUNIT_NPM-NEXT:  entry:
679; IS__TUNIT_NPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[U]], -1
680; IS__TUNIT_NPM-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
681; IS__TUNIT_NPM:       if.then:
682; IS__TUNIT_NPM-NEXT:    [[ADD:%.*]] = add nuw nsw i32 [[U]], 1
683; IS__TUNIT_NPM-NEXT:    br label [[RETURN:%.*]]
684; IS__TUNIT_NPM:       if.else:
685; IS__TUNIT_NPM-NEXT:    br label [[RETURN]]
686; IS__TUNIT_NPM:       return:
687; IS__TUNIT_NPM-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ [[ADD]], [[IF_THEN]] ], [ 1, [[IF_ELSE]] ]
688; IS__TUNIT_NPM-NEXT:    ret i32 [[RETVAL_0]]
689;
690; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
691; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test4-f2
692; IS__CGSCC_OPM-SAME: (i32 [[U:%.*]]) #[[ATTR3]] {
693; IS__CGSCC_OPM-NEXT:  entry:
694; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[U]], -1
695; IS__CGSCC_OPM-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
696; IS__CGSCC_OPM:       if.then:
697; IS__CGSCC_OPM-NEXT:    [[ADD:%.*]] = add nuw nsw i32 [[U]], 1
698; IS__CGSCC_OPM-NEXT:    br label [[RETURN:%.*]]
699; IS__CGSCC_OPM:       if.else:
700; IS__CGSCC_OPM-NEXT:    br label [[RETURN]]
701; IS__CGSCC_OPM:       return:
702; IS__CGSCC_OPM-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ [[ADD]], [[IF_THEN]] ], [ 1, [[IF_ELSE]] ]
703; IS__CGSCC_OPM-NEXT:    ret i32 [[RETVAL_0]]
704;
705; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
706; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test4-f2
707; IS__CGSCC_NPM-SAME: (i32 [[U:%.*]]) #[[ATTR2]] {
708; IS__CGSCC_NPM-NEXT:  entry:
709; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[U]], -1
710; IS__CGSCC_NPM-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
711; IS__CGSCC_NPM:       if.then:
712; IS__CGSCC_NPM-NEXT:    [[ADD:%.*]] = add nuw nsw i32 [[U]], 1
713; IS__CGSCC_NPM-NEXT:    br label [[RETURN:%.*]]
714; IS__CGSCC_NPM:       if.else:
715; IS__CGSCC_NPM-NEXT:    br label [[RETURN]]
716; IS__CGSCC_NPM:       return:
717; IS__CGSCC_NPM-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ [[ADD]], [[IF_THEN]] ], [ 1, [[IF_ELSE]] ]
718; IS__CGSCC_NPM-NEXT:    ret i32 [[RETVAL_0]]
719;
720entry:
721  %cmp = icmp sgt i32 %u, -1
722  br i1 %cmp, label %if.then, label %if.else
723
724if.then:                                          ; preds = %entry
725  %add = add nuw nsw i32 %u, 1
726  br label %return
727
728if.else:                                          ; preds = %entry
729  br label %return
730
731return:                                           ; preds = %if.else, %if.then
732  %retval.0 = phi i32 [ %add, %if.then ], [ 1, %if.else ]
733  ret i32 %retval.0
734}
735
736
737define dso_local i32 @test4-g2(i32 %u) {
738; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
739; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@test4-g2
740; IS__TUNIT_OPM-SAME: (i32 [[U:%.*]]) #[[ATTR2]] {
741; IS__TUNIT_OPM-NEXT:  entry:
742; IS__TUNIT_OPM-NEXT:    [[CALL:%.*]] = tail call i32 @test4-f2(i32 [[U]]) #[[ATTR5]]
743; IS__TUNIT_OPM-NEXT:    ret i32 [[CALL]]
744;
745; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
746; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@test4-g2
747; IS__TUNIT_NPM-SAME: (i32 [[U:%.*]]) #[[ATTR1]] {
748; IS__TUNIT_NPM-NEXT:  entry:
749; IS__TUNIT_NPM-NEXT:    [[CALL:%.*]] = tail call i32 @test4-f2(i32 [[U]]) #[[ATTR4]], !range [[RNG3:![0-9]+]]
750; IS__TUNIT_NPM-NEXT:    ret i32 [[CALL]]
751;
752; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
753; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test4-g2
754; IS__CGSCC_OPM-SAME: (i32 [[U:%.*]]) #[[ATTR4]] {
755; IS__CGSCC_OPM-NEXT:  entry:
756; IS__CGSCC_OPM-NEXT:    [[CALL:%.*]] = tail call i32 @test4-f2(i32 [[U]]) #[[ATTR7]]
757; IS__CGSCC_OPM-NEXT:    ret i32 [[CALL]]
758;
759; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
760; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test4-g2
761; IS__CGSCC_NPM-SAME: (i32 [[U:%.*]]) #[[ATTR3]] {
762; IS__CGSCC_NPM-NEXT:  entry:
763; IS__CGSCC_NPM-NEXT:    [[CALL:%.*]] = tail call i32 @test4-f2(i32 [[U]]) #[[ATTR6]]
764; IS__CGSCC_NPM-NEXT:    ret i32 [[CALL]]
765;
766entry:
767  %call = tail call i32 @test4-f2(i32 %u)
768  ret i32 %call
769}
770
771define dso_local i32 @test-5() {
772; IS__TUNIT____-LABEL: define {{[^@]+}}@test-5() {
773; IS__TUNIT____-NEXT:  entry:
774; IS__TUNIT____-NEXT:    [[CALL:%.*]] = call i32 @rec(i32 noundef 0)
775; IS__TUNIT____-NEXT:    ret i32 [[CALL]]
776;
777; IS__CGSCC____-LABEL: define {{[^@]+}}@test-5() {
778; IS__CGSCC____-NEXT:  entry:
779; IS__CGSCC____-NEXT:    [[CALL:%.*]] = call noundef i32 @rec(i32 noundef 0)
780; IS__CGSCC____-NEXT:    ret i32 [[CALL]]
781;
782entry:
783  %call = call i32 @rec(i32 0)
784  ret i32 %call
785}
786define internal i32 @rec(i32 %depth) {
787; CHECK-LABEL: define {{[^@]+}}@rec
788; CHECK-SAME: (i32 [[DEPTH:%.*]]) {
789; CHECK-NEXT:  entry:
790; CHECK-NEXT:    [[CALL:%.*]] = call i32 @foo(i32 [[DEPTH]])
791; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp ne i32 [[CALL]], 0
792; CHECK-NEXT:    br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
793; CHECK:       if.then:
794; CHECK-NEXT:    br label [[RETURN:%.*]]
795; CHECK:       if.end:
796; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[DEPTH]], 10
797; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN1:%.*]], label [[IF_END3:%.*]]
798; CHECK:       if.then1:
799; CHECK-NEXT:    [[ADD:%.*]] = add nsw i32 [[DEPTH]], 1
800; CHECK-NEXT:    [[CALL2:%.*]] = call i32 @rec(i32 [[ADD]])
801; CHECK-NEXT:    br label [[IF_END3]]
802; CHECK:       if.end3:
803; CHECK-NEXT:    br label [[RETURN]]
804; CHECK:       return:
805; CHECK-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ 0, [[IF_THEN]] ], [ 1, [[IF_END3]] ]
806; CHECK-NEXT:    ret i32 [[RETVAL_0]]
807;
808entry:
809  %call = call i32 @foo(i32 %depth)
810  %tobool = icmp ne i32 %call, 0
811  br i1 %tobool, label %if.then, label %if.end
812
813if.then:                                          ; preds = %entry
814  br label %return
815
816if.end:                                           ; preds = %entry
817  %cmp = icmp slt i32 %depth, 10
818  br i1 %cmp, label %if.then1, label %if.end3
819
820if.then1:                                         ; preds = %if.end
821  %add = add nsw i32 %depth, 1
822  %call2 = call i32 @rec(i32 %add)
823  br label %if.end3
824
825if.end3:                                          ; preds = %if.then1, %if.end
826  br label %return
827
828return:                                           ; preds = %if.end3, %if.then
829  %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end3 ]
830  ret i32 %retval.0
831}
832declare dso_local i32 @foo(i32)
833
834
835; Examples taken from https://llvm.discourse.group/t/impossible-condition-optimization/461/1
836;
837; The important part is that we return a constant (false)
838;
839; {
840
841; FIXME: All but the return is not needed anymore
842define dso_local zeroext i1 @phi(i32 %arg) {
843; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
844; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@phi
845; IS__TUNIT_OPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR2]] {
846; IS__TUNIT_OPM-NEXT:  bb:
847; IS__TUNIT_OPM-NEXT:    [[TMP:%.*]] = icmp sgt i32 [[ARG]], 5
848; IS__TUNIT_OPM-NEXT:    br i1 [[TMP]], label [[BB1:%.*]], label [[BB2:%.*]]
849; IS__TUNIT_OPM:       bb1:
850; IS__TUNIT_OPM-NEXT:    br label [[BB3:%.*]]
851; IS__TUNIT_OPM:       bb2:
852; IS__TUNIT_OPM-NEXT:    br label [[BB3]]
853; IS__TUNIT_OPM:       bb3:
854; IS__TUNIT_OPM-NEXT:    [[DOT02:%.*]] = phi i32 [ 1, [[BB1]] ], [ 2, [[BB2]] ]
855; IS__TUNIT_OPM-NEXT:    [[TMP4:%.*]] = icmp sgt i32 [[ARG]], 10
856; IS__TUNIT_OPM-NEXT:    br i1 [[TMP4]], label [[BB5:%.*]], label [[BB7:%.*]]
857; IS__TUNIT_OPM:       bb5:
858; IS__TUNIT_OPM-NEXT:    [[TMP6:%.*]] = add nsw i32 [[DOT02]], 1
859; IS__TUNIT_OPM-NEXT:    br label [[BB9:%.*]]
860; IS__TUNIT_OPM:       bb7:
861; IS__TUNIT_OPM-NEXT:    [[TMP8:%.*]] = add nsw i32 [[DOT02]], 2
862; IS__TUNIT_OPM-NEXT:    br label [[BB9]]
863; IS__TUNIT_OPM:       bb9:
864; IS__TUNIT_OPM-NEXT:    [[DOT01:%.*]] = phi i32 [ [[TMP6]], [[BB5]] ], [ [[TMP8]], [[BB7]] ]
865; IS__TUNIT_OPM-NEXT:    [[TMP10:%.*]] = icmp eq i32 [[DOT01]], 5
866; IS__TUNIT_OPM-NEXT:    br i1 [[TMP10]], label [[BB11:%.*]], label [[BB12:%.*]]
867; IS__TUNIT_OPM:       bb11:
868; IS__TUNIT_OPM-NEXT:    br label [[BB13:%.*]]
869; IS__TUNIT_OPM:       bb12:
870; IS__TUNIT_OPM-NEXT:    br label [[BB13]]
871; IS__TUNIT_OPM:       bb13:
872; IS__TUNIT_OPM-NEXT:    [[DOT0:%.*]] = phi i1 [ true, [[BB11]] ], [ false, [[BB12]] ]
873; IS__TUNIT_OPM-NEXT:    ret i1 [[DOT0]]
874;
875; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
876; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@phi
877; IS__TUNIT_NPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR1]] {
878; IS__TUNIT_NPM-NEXT:  bb:
879; IS__TUNIT_NPM-NEXT:    [[TMP:%.*]] = icmp sgt i32 [[ARG]], 5
880; IS__TUNIT_NPM-NEXT:    br i1 [[TMP]], label [[BB1:%.*]], label [[BB2:%.*]]
881; IS__TUNIT_NPM:       bb1:
882; IS__TUNIT_NPM-NEXT:    br label [[BB3:%.*]]
883; IS__TUNIT_NPM:       bb2:
884; IS__TUNIT_NPM-NEXT:    br label [[BB3]]
885; IS__TUNIT_NPM:       bb3:
886; IS__TUNIT_NPM-NEXT:    [[DOT02:%.*]] = phi i32 [ 1, [[BB1]] ], [ 2, [[BB2]] ]
887; IS__TUNIT_NPM-NEXT:    [[TMP4:%.*]] = icmp sgt i32 [[ARG]], 10
888; IS__TUNIT_NPM-NEXT:    br i1 [[TMP4]], label [[BB5:%.*]], label [[BB7:%.*]]
889; IS__TUNIT_NPM:       bb5:
890; IS__TUNIT_NPM-NEXT:    [[TMP6:%.*]] = add nsw i32 [[DOT02]], 1
891; IS__TUNIT_NPM-NEXT:    br label [[BB9:%.*]]
892; IS__TUNIT_NPM:       bb7:
893; IS__TUNIT_NPM-NEXT:    [[TMP8:%.*]] = add nsw i32 [[DOT02]], 2
894; IS__TUNIT_NPM-NEXT:    br label [[BB9]]
895; IS__TUNIT_NPM:       bb9:
896; IS__TUNIT_NPM-NEXT:    [[DOT01:%.*]] = phi i32 [ [[TMP6]], [[BB5]] ], [ [[TMP8]], [[BB7]] ]
897; IS__TUNIT_NPM-NEXT:    [[TMP10:%.*]] = icmp eq i32 [[DOT01]], 5
898; IS__TUNIT_NPM-NEXT:    br i1 [[TMP10]], label [[BB11:%.*]], label [[BB12:%.*]]
899; IS__TUNIT_NPM:       bb11:
900; IS__TUNIT_NPM-NEXT:    br label [[BB13:%.*]]
901; IS__TUNIT_NPM:       bb12:
902; IS__TUNIT_NPM-NEXT:    br label [[BB13]]
903; IS__TUNIT_NPM:       bb13:
904; IS__TUNIT_NPM-NEXT:    [[DOT0:%.*]] = phi i1 [ true, [[BB11]] ], [ false, [[BB12]] ]
905; IS__TUNIT_NPM-NEXT:    ret i1 [[DOT0]]
906;
907; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
908; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@phi
909; IS__CGSCC_OPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR3]] {
910; IS__CGSCC_OPM-NEXT:  bb:
911; IS__CGSCC_OPM-NEXT:    [[TMP:%.*]] = icmp sgt i32 [[ARG]], 5
912; IS__CGSCC_OPM-NEXT:    br i1 [[TMP]], label [[BB1:%.*]], label [[BB2:%.*]]
913; IS__CGSCC_OPM:       bb1:
914; IS__CGSCC_OPM-NEXT:    br label [[BB3:%.*]]
915; IS__CGSCC_OPM:       bb2:
916; IS__CGSCC_OPM-NEXT:    br label [[BB3]]
917; IS__CGSCC_OPM:       bb3:
918; IS__CGSCC_OPM-NEXT:    [[DOT02:%.*]] = phi i32 [ 1, [[BB1]] ], [ 2, [[BB2]] ]
919; IS__CGSCC_OPM-NEXT:    [[TMP4:%.*]] = icmp sgt i32 [[ARG]], 10
920; IS__CGSCC_OPM-NEXT:    br i1 [[TMP4]], label [[BB5:%.*]], label [[BB7:%.*]]
921; IS__CGSCC_OPM:       bb5:
922; IS__CGSCC_OPM-NEXT:    [[TMP6:%.*]] = add nsw i32 [[DOT02]], 1
923; IS__CGSCC_OPM-NEXT:    br label [[BB9:%.*]]
924; IS__CGSCC_OPM:       bb7:
925; IS__CGSCC_OPM-NEXT:    [[TMP8:%.*]] = add nsw i32 [[DOT02]], 2
926; IS__CGSCC_OPM-NEXT:    br label [[BB9]]
927; IS__CGSCC_OPM:       bb9:
928; IS__CGSCC_OPM-NEXT:    [[DOT01:%.*]] = phi i32 [ [[TMP6]], [[BB5]] ], [ [[TMP8]], [[BB7]] ]
929; IS__CGSCC_OPM-NEXT:    [[TMP10:%.*]] = icmp eq i32 [[DOT01]], 5
930; IS__CGSCC_OPM-NEXT:    br i1 [[TMP10]], label [[BB11:%.*]], label [[BB12:%.*]]
931; IS__CGSCC_OPM:       bb11:
932; IS__CGSCC_OPM-NEXT:    br label [[BB13:%.*]]
933; IS__CGSCC_OPM:       bb12:
934; IS__CGSCC_OPM-NEXT:    br label [[BB13]]
935; IS__CGSCC_OPM:       bb13:
936; IS__CGSCC_OPM-NEXT:    [[DOT0:%.*]] = phi i1 [ true, [[BB11]] ], [ false, [[BB12]] ]
937; IS__CGSCC_OPM-NEXT:    ret i1 [[DOT0]]
938;
939; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
940; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@phi
941; IS__CGSCC_NPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR2]] {
942; IS__CGSCC_NPM-NEXT:  bb:
943; IS__CGSCC_NPM-NEXT:    [[TMP:%.*]] = icmp sgt i32 [[ARG]], 5
944; IS__CGSCC_NPM-NEXT:    br i1 [[TMP]], label [[BB1:%.*]], label [[BB2:%.*]]
945; IS__CGSCC_NPM:       bb1:
946; IS__CGSCC_NPM-NEXT:    br label [[BB3:%.*]]
947; IS__CGSCC_NPM:       bb2:
948; IS__CGSCC_NPM-NEXT:    br label [[BB3]]
949; IS__CGSCC_NPM:       bb3:
950; IS__CGSCC_NPM-NEXT:    [[DOT02:%.*]] = phi i32 [ 1, [[BB1]] ], [ 2, [[BB2]] ]
951; IS__CGSCC_NPM-NEXT:    [[TMP4:%.*]] = icmp sgt i32 [[ARG]], 10
952; IS__CGSCC_NPM-NEXT:    br i1 [[TMP4]], label [[BB5:%.*]], label [[BB7:%.*]]
953; IS__CGSCC_NPM:       bb5:
954; IS__CGSCC_NPM-NEXT:    [[TMP6:%.*]] = add nsw i32 [[DOT02]], 1
955; IS__CGSCC_NPM-NEXT:    br label [[BB9:%.*]]
956; IS__CGSCC_NPM:       bb7:
957; IS__CGSCC_NPM-NEXT:    [[TMP8:%.*]] = add nsw i32 [[DOT02]], 2
958; IS__CGSCC_NPM-NEXT:    br label [[BB9]]
959; IS__CGSCC_NPM:       bb9:
960; IS__CGSCC_NPM-NEXT:    [[DOT01:%.*]] = phi i32 [ [[TMP6]], [[BB5]] ], [ [[TMP8]], [[BB7]] ]
961; IS__CGSCC_NPM-NEXT:    [[TMP10:%.*]] = icmp eq i32 [[DOT01]], 5
962; IS__CGSCC_NPM-NEXT:    br i1 [[TMP10]], label [[BB11:%.*]], label [[BB12:%.*]]
963; IS__CGSCC_NPM:       bb11:
964; IS__CGSCC_NPM-NEXT:    br label [[BB13:%.*]]
965; IS__CGSCC_NPM:       bb12:
966; IS__CGSCC_NPM-NEXT:    br label [[BB13]]
967; IS__CGSCC_NPM:       bb13:
968; IS__CGSCC_NPM-NEXT:    [[DOT0:%.*]] = phi i1 [ true, [[BB11]] ], [ false, [[BB12]] ]
969; IS__CGSCC_NPM-NEXT:    ret i1 [[DOT0]]
970;
971bb:
972  %tmp = icmp sgt i32 %arg, 5
973  br i1 %tmp, label %bb1, label %bb2
974
975bb1:                                              ; preds = %bb
976  br label %bb3
977
978bb2:                                              ; preds = %bb
979  br label %bb3
980
981bb3:                                              ; preds = %bb2, %bb1
982  %.02 = phi i32 [ 1, %bb1 ], [ 2, %bb2 ]
983  %tmp4 = icmp sgt i32 %arg, 10
984  br i1 %tmp4, label %bb5, label %bb7
985
986bb5:                                              ; preds = %bb3
987  %tmp6 = add nsw i32 %.02, 1
988  br label %bb9
989
990bb7:                                              ; preds = %bb3
991  %tmp8 = add nsw i32 %.02, 2
992  br label %bb9
993
994bb9:                                              ; preds = %bb7, %bb5
995  %.01 = phi i32 [ %tmp6, %bb5 ], [ %tmp8, %bb7 ]
996  %tmp10 = icmp eq i32 %.01, 5
997  br i1 %tmp10, label %bb11, label %bb12
998
999bb11:                                             ; preds = %bb9
1000  br label %bb13
1001
1002bb12:                                             ; preds = %bb9
1003  br label %bb13
1004
1005bb13:                                             ; preds = %bb12, %bb11
1006  %.0 = phi i1 [ true, %bb11 ], [ false, %bb12 ]
1007  ret i1 %.0
1008}
1009
1010define dso_local i1 @select(i32 %a) local_unnamed_addr #0 {
1011; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1012; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@select
1013; IS__TUNIT_OPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
1014; IS__TUNIT_OPM-NEXT:  entry:
1015; IS__TUNIT_OPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1016; IS__TUNIT_OPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1017; IS__TUNIT_OPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1018; IS__TUNIT_OPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1019; IS__TUNIT_OPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1020; IS__TUNIT_OPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1021; IS__TUNIT_OPM-NEXT:    ret i1 [[CMP6]]
1022;
1023; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1024; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@select
1025; IS__TUNIT_NPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR1]] {
1026; IS__TUNIT_NPM-NEXT:  entry:
1027; IS__TUNIT_NPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1028; IS__TUNIT_NPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1029; IS__TUNIT_NPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1030; IS__TUNIT_NPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1031; IS__TUNIT_NPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1032; IS__TUNIT_NPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1033; IS__TUNIT_NPM-NEXT:    ret i1 [[CMP6]]
1034;
1035; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1036; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@select
1037; IS__CGSCC_OPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR3]] {
1038; IS__CGSCC_OPM-NEXT:  entry:
1039; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1040; IS__CGSCC_OPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1041; IS__CGSCC_OPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1042; IS__CGSCC_OPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1043; IS__CGSCC_OPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1044; IS__CGSCC_OPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1045; IS__CGSCC_OPM-NEXT:    ret i1 [[CMP6]]
1046;
1047; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1048; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@select
1049; IS__CGSCC_NPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
1050; IS__CGSCC_NPM-NEXT:  entry:
1051; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1052; IS__CGSCC_NPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1053; IS__CGSCC_NPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1054; IS__CGSCC_NPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1055; IS__CGSCC_NPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1056; IS__CGSCC_NPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1057; IS__CGSCC_NPM-NEXT:    ret i1 [[CMP6]]
1058;
1059entry:
1060  %cmp = icmp sgt i32 %a, 5
1061  %. = select i1 %cmp, i32 1, i32 2
1062  %cmp1 = icmp sgt i32 %a, 10
1063  %y.0.v = select i1 %cmp1, i32 1, i32 2
1064  %y.0 = add nuw nsw i32 %., %y.0.v
1065  %cmp6 = icmp eq i32 %y.0, 5
1066  ret i1 %cmp6
1067}
1068
1069define dso_local i32 @select_zext(i32 %a) local_unnamed_addr #0 {
1070; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1071; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@select_zext
1072; IS__TUNIT_OPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
1073; IS__TUNIT_OPM-NEXT:  entry:
1074; IS__TUNIT_OPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1075; IS__TUNIT_OPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1076; IS__TUNIT_OPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1077; IS__TUNIT_OPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1078; IS__TUNIT_OPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1079; IS__TUNIT_OPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1080; IS__TUNIT_OPM-NEXT:    [[DOT13:%.*]] = zext i1 [[CMP6]] to i32
1081; IS__TUNIT_OPM-NEXT:    ret i32 [[DOT13]]
1082;
1083; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1084; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@select_zext
1085; IS__TUNIT_NPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR1]] {
1086; IS__TUNIT_NPM-NEXT:  entry:
1087; IS__TUNIT_NPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1088; IS__TUNIT_NPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1089; IS__TUNIT_NPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1090; IS__TUNIT_NPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1091; IS__TUNIT_NPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1092; IS__TUNIT_NPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1093; IS__TUNIT_NPM-NEXT:    [[DOT13:%.*]] = zext i1 [[CMP6]] to i32
1094; IS__TUNIT_NPM-NEXT:    ret i32 [[DOT13]]
1095;
1096; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1097; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@select_zext
1098; IS__CGSCC_OPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR3]] {
1099; IS__CGSCC_OPM-NEXT:  entry:
1100; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1101; IS__CGSCC_OPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1102; IS__CGSCC_OPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1103; IS__CGSCC_OPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1104; IS__CGSCC_OPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1105; IS__CGSCC_OPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1106; IS__CGSCC_OPM-NEXT:    [[DOT13:%.*]] = zext i1 [[CMP6]] to i32
1107; IS__CGSCC_OPM-NEXT:    ret i32 [[DOT13]]
1108;
1109; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1110; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@select_zext
1111; IS__CGSCC_NPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
1112; IS__CGSCC_NPM-NEXT:  entry:
1113; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1114; IS__CGSCC_NPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1115; IS__CGSCC_NPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1116; IS__CGSCC_NPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1117; IS__CGSCC_NPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1118; IS__CGSCC_NPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1119; IS__CGSCC_NPM-NEXT:    [[DOT13:%.*]] = zext i1 [[CMP6]] to i32
1120; IS__CGSCC_NPM-NEXT:    ret i32 [[DOT13]]
1121;
1122entry:
1123  %cmp = icmp sgt i32 %a, 5
1124  %. = select i1 %cmp, i32 1, i32 2
1125  %cmp1 = icmp sgt i32 %a, 10
1126  %y.0.v = select i1 %cmp1, i32 1, i32 2
1127  %y.0 = add nuw nsw i32 %., %y.0.v
1128  %cmp6 = icmp eq i32 %y.0, 5
1129  %.13 = zext i1 %cmp6 to i32
1130  ret i32 %.13
1131}
1132
1133define dso_local i64 @select_int2ptr_bitcast_ptr2int(i32 %a) local_unnamed_addr #0 {
1134; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1135; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@select_int2ptr_bitcast_ptr2int
1136; IS__TUNIT_OPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
1137; IS__TUNIT_OPM-NEXT:  entry:
1138; IS__TUNIT_OPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1139; IS__TUNIT_OPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1140; IS__TUNIT_OPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1141; IS__TUNIT_OPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1142; IS__TUNIT_OPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1143; IS__TUNIT_OPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1144; IS__TUNIT_OPM-NEXT:    [[I2P:%.*]] = inttoptr i1 [[CMP6]] to i1*
1145; IS__TUNIT_OPM-NEXT:    [[BC:%.*]] = bitcast i1* [[I2P]] to i32*
1146; IS__TUNIT_OPM-NEXT:    [[P2I:%.*]] = ptrtoint i32* [[BC]] to i64
1147; IS__TUNIT_OPM-NEXT:    ret i64 [[P2I]]
1148;
1149; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1150; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@select_int2ptr_bitcast_ptr2int
1151; IS__TUNIT_NPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR1]] {
1152; IS__TUNIT_NPM-NEXT:  entry:
1153; IS__TUNIT_NPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1154; IS__TUNIT_NPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1155; IS__TUNIT_NPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1156; IS__TUNIT_NPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1157; IS__TUNIT_NPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1158; IS__TUNIT_NPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1159; IS__TUNIT_NPM-NEXT:    [[I2P:%.*]] = inttoptr i1 [[CMP6]] to i1*
1160; IS__TUNIT_NPM-NEXT:    [[BC:%.*]] = bitcast i1* [[I2P]] to i32*
1161; IS__TUNIT_NPM-NEXT:    [[P2I:%.*]] = ptrtoint i32* [[BC]] to i64
1162; IS__TUNIT_NPM-NEXT:    ret i64 [[P2I]]
1163;
1164; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1165; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@select_int2ptr_bitcast_ptr2int
1166; IS__CGSCC_OPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR3]] {
1167; IS__CGSCC_OPM-NEXT:  entry:
1168; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1169; IS__CGSCC_OPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1170; IS__CGSCC_OPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1171; IS__CGSCC_OPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1172; IS__CGSCC_OPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1173; IS__CGSCC_OPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1174; IS__CGSCC_OPM-NEXT:    [[I2P:%.*]] = inttoptr i1 [[CMP6]] to i1*
1175; IS__CGSCC_OPM-NEXT:    [[BC:%.*]] = bitcast i1* [[I2P]] to i32*
1176; IS__CGSCC_OPM-NEXT:    [[P2I:%.*]] = ptrtoint i32* [[BC]] to i64
1177; IS__CGSCC_OPM-NEXT:    ret i64 [[P2I]]
1178;
1179; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1180; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@select_int2ptr_bitcast_ptr2int
1181; IS__CGSCC_NPM-SAME: (i32 [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
1182; IS__CGSCC_NPM-NEXT:  entry:
1183; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[A]], 5
1184; IS__CGSCC_NPM-NEXT:    [[DOT:%.*]] = select i1 [[CMP]], i32 1, i32 2
1185; IS__CGSCC_NPM-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[A]], 10
1186; IS__CGSCC_NPM-NEXT:    [[Y_0_V:%.*]] = select i1 [[CMP1]], i32 1, i32 2
1187; IS__CGSCC_NPM-NEXT:    [[Y_0:%.*]] = add nuw nsw i32 [[DOT]], [[Y_0_V]]
1188; IS__CGSCC_NPM-NEXT:    [[CMP6:%.*]] = icmp eq i32 [[Y_0]], 5
1189; IS__CGSCC_NPM-NEXT:    [[I2P:%.*]] = inttoptr i1 [[CMP6]] to i1*
1190; IS__CGSCC_NPM-NEXT:    [[BC:%.*]] = bitcast i1* [[I2P]] to i32*
1191; IS__CGSCC_NPM-NEXT:    [[P2I:%.*]] = ptrtoint i32* [[BC]] to i64
1192; IS__CGSCC_NPM-NEXT:    ret i64 [[P2I]]
1193;
1194entry:
1195  %cmp = icmp sgt i32 %a, 5
1196  %. = select i1 %cmp, i32 1, i32 2
1197  %cmp1 = icmp sgt i32 %a, 10
1198  %y.0.v = select i1 %cmp1, i32 1, i32 2
1199  %y.0 = add nuw nsw i32 %., %y.0.v
1200  %cmp6 = icmp eq i32 %y.0, 5
1201  %i2p = inttoptr i1 %cmp6 to i1*
1202  %bc = bitcast i1* %i2p to i32*
1203  %p2i = ptrtoint i32* %bc to i64
1204  ret i64 %p2i
1205}
1206
1207; }
1208
1209define i1 @f_fcmp(float %a, float %b) {
1210; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1211; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@f_fcmp
1212; IS__TUNIT_OPM-SAME: (float [[A:%.*]], float [[B:%.*]]) #[[ATTR2]] {
1213; IS__TUNIT_OPM-NEXT:    [[R:%.*]] = fcmp uge float [[A]], [[B]]
1214; IS__TUNIT_OPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1215; IS__TUNIT_OPM-NEXT:    ret i1 [[S]]
1216;
1217; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1218; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@f_fcmp
1219; IS__TUNIT_NPM-SAME: (float [[A:%.*]], float [[B:%.*]]) #[[ATTR1]] {
1220; IS__TUNIT_NPM-NEXT:    [[R:%.*]] = fcmp uge float [[A]], [[B]]
1221; IS__TUNIT_NPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1222; IS__TUNIT_NPM-NEXT:    ret i1 [[S]]
1223;
1224; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1225; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f_fcmp
1226; IS__CGSCC_OPM-SAME: (float [[A:%.*]], float [[B:%.*]]) #[[ATTR3]] {
1227; IS__CGSCC_OPM-NEXT:    [[R:%.*]] = fcmp uge float [[A]], [[B]]
1228; IS__CGSCC_OPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1229; IS__CGSCC_OPM-NEXT:    ret i1 [[S]]
1230;
1231; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1232; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f_fcmp
1233; IS__CGSCC_NPM-SAME: (float [[A:%.*]], float [[B:%.*]]) #[[ATTR2]] {
1234; IS__CGSCC_NPM-NEXT:    [[R:%.*]] = fcmp uge float [[A]], [[B]]
1235; IS__CGSCC_NPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1236; IS__CGSCC_NPM-NEXT:    ret i1 [[S]]
1237;
1238  %r = fcmp uge float %a, %b
1239  %s = select i1 %r, i1 %r, i1 0
1240  ret i1 %s
1241}
1242define i1 @d_fcmp(double %a, double %b) {
1243; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1244; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@d_fcmp
1245; IS__TUNIT_OPM-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[ATTR2]] {
1246; IS__TUNIT_OPM-NEXT:    [[R:%.*]] = fcmp oeq double [[A]], [[B]]
1247; IS__TUNIT_OPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1248; IS__TUNIT_OPM-NEXT:    ret i1 [[S]]
1249;
1250; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1251; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@d_fcmp
1252; IS__TUNIT_NPM-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[ATTR1]] {
1253; IS__TUNIT_NPM-NEXT:    [[R:%.*]] = fcmp oeq double [[A]], [[B]]
1254; IS__TUNIT_NPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1255; IS__TUNIT_NPM-NEXT:    ret i1 [[S]]
1256;
1257; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1258; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@d_fcmp
1259; IS__CGSCC_OPM-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[ATTR3]] {
1260; IS__CGSCC_OPM-NEXT:    [[R:%.*]] = fcmp oeq double [[A]], [[B]]
1261; IS__CGSCC_OPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1262; IS__CGSCC_OPM-NEXT:    ret i1 [[S]]
1263;
1264; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1265; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@d_fcmp
1266; IS__CGSCC_NPM-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[ATTR2]] {
1267; IS__CGSCC_NPM-NEXT:    [[R:%.*]] = fcmp oeq double [[A]], [[B]]
1268; IS__CGSCC_NPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1269; IS__CGSCC_NPM-NEXT:    ret i1 [[S]]
1270;
1271  %r = fcmp oeq double %a, %b
1272  %s = select i1 %r, i1 %r, i1 0
1273  ret i1 %s
1274}
1275define i1 @dp_icmp(double* %a, double* %b) {
1276; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1277; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@dp_icmp
1278; IS__TUNIT_OPM-SAME: (double* nofree readnone [[A:%.*]], double* nofree readnone [[B:%.*]]) #[[ATTR2]] {
1279; IS__TUNIT_OPM-NEXT:    [[R:%.*]] = icmp sge double* [[A]], [[B]]
1280; IS__TUNIT_OPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1281; IS__TUNIT_OPM-NEXT:    ret i1 [[S]]
1282;
1283; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1284; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@dp_icmp
1285; IS__TUNIT_NPM-SAME: (double* nofree readnone [[A:%.*]], double* nofree readnone [[B:%.*]]) #[[ATTR1]] {
1286; IS__TUNIT_NPM-NEXT:    [[R:%.*]] = icmp sge double* [[A]], [[B]]
1287; IS__TUNIT_NPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1288; IS__TUNIT_NPM-NEXT:    ret i1 [[S]]
1289;
1290; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1291; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@dp_icmp
1292; IS__CGSCC_OPM-SAME: (double* nofree readnone [[A:%.*]], double* nofree readnone [[B:%.*]]) #[[ATTR3]] {
1293; IS__CGSCC_OPM-NEXT:    [[R:%.*]] = icmp sge double* [[A]], [[B]]
1294; IS__CGSCC_OPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1295; IS__CGSCC_OPM-NEXT:    ret i1 [[S]]
1296;
1297; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1298; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@dp_icmp
1299; IS__CGSCC_NPM-SAME: (double* nofree readnone [[A:%.*]], double* nofree readnone [[B:%.*]]) #[[ATTR2]] {
1300; IS__CGSCC_NPM-NEXT:    [[R:%.*]] = icmp sge double* [[A]], [[B]]
1301; IS__CGSCC_NPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1302; IS__CGSCC_NPM-NEXT:    ret i1 [[S]]
1303;
1304  %r = icmp sge double* %a, %b
1305  %s = select i1 %r, i1 %r, i1 0
1306  ret i1 %s
1307}
1308define i1 @ip_icmp(i8* %a, i8* %b) {
1309; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1310; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@ip_icmp
1311; IS__TUNIT_OPM-SAME: (i8* nofree readnone [[A:%.*]], i8* nofree readnone [[B:%.*]]) #[[ATTR2]] {
1312; IS__TUNIT_OPM-NEXT:    [[R:%.*]] = icmp ult i8* [[A]], [[B]]
1313; IS__TUNIT_OPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1314; IS__TUNIT_OPM-NEXT:    ret i1 [[S]]
1315;
1316; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1317; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@ip_icmp
1318; IS__TUNIT_NPM-SAME: (i8* nofree readnone [[A:%.*]], i8* nofree readnone [[B:%.*]]) #[[ATTR1]] {
1319; IS__TUNIT_NPM-NEXT:    [[R:%.*]] = icmp ult i8* [[A]], [[B]]
1320; IS__TUNIT_NPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1321; IS__TUNIT_NPM-NEXT:    ret i1 [[S]]
1322;
1323; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1324; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@ip_icmp
1325; IS__CGSCC_OPM-SAME: (i8* nofree readnone [[A:%.*]], i8* nofree readnone [[B:%.*]]) #[[ATTR3]] {
1326; IS__CGSCC_OPM-NEXT:    [[R:%.*]] = icmp ult i8* [[A]], [[B]]
1327; IS__CGSCC_OPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1328; IS__CGSCC_OPM-NEXT:    ret i1 [[S]]
1329;
1330; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1331; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@ip_icmp
1332; IS__CGSCC_NPM-SAME: (i8* nofree readnone [[A:%.*]], i8* nofree readnone [[B:%.*]]) #[[ATTR2]] {
1333; IS__CGSCC_NPM-NEXT:    [[R:%.*]] = icmp ult i8* [[A]], [[B]]
1334; IS__CGSCC_NPM-NEXT:    [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false
1335; IS__CGSCC_NPM-NEXT:    ret i1 [[S]]
1336;
1337  %r = icmp ult i8* %a, %b
1338  %s = select i1 %r, i1 %r, i1 0
1339  ret i1 %s
1340}
1341define i1 @fcmp_caller(float %fa, float %fb, double %da, double %db, double* %dpa, double* %dpb, i8* %ipa, i8* %ipb) {
1342; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1343; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@fcmp_caller
1344; IS__TUNIT_OPM-SAME: (float [[FA:%.*]], float [[FB:%.*]], double [[DA:%.*]], double [[DB:%.*]], double* nofree readnone [[DPA:%.*]], double* nofree readnone [[DPB:%.*]], i8* nofree readnone [[IPA:%.*]], i8* nofree readnone [[IPB:%.*]]) #[[ATTR2]] {
1345; IS__TUNIT_OPM-NEXT:    [[R1:%.*]] = call i1 @f_fcmp(float [[FA]], float [[FB]]) #[[ATTR5]]
1346; IS__TUNIT_OPM-NEXT:    [[R2:%.*]] = call i1 @d_fcmp(double [[DA]], double [[DB]]) #[[ATTR5]]
1347; IS__TUNIT_OPM-NEXT:    [[R3:%.*]] = call i1 @dp_icmp(double* noalias nofree readnone [[DPA]], double* noalias nofree readnone [[DPB]]) #[[ATTR5]]
1348; IS__TUNIT_OPM-NEXT:    [[R4:%.*]] = call i1 @ip_icmp(i8* noalias nofree readnone [[IPA]], i8* noalias nofree readnone [[IPB]]) #[[ATTR5]]
1349; IS__TUNIT_OPM-NEXT:    [[O1:%.*]] = or i1 [[R1]], [[R2]]
1350; IS__TUNIT_OPM-NEXT:    [[O2:%.*]] = or i1 [[R3]], [[R4]]
1351; IS__TUNIT_OPM-NEXT:    [[O3:%.*]] = or i1 [[O1]], [[O2]]
1352; IS__TUNIT_OPM-NEXT:    ret i1 [[O3]]
1353;
1354; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1355; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@fcmp_caller
1356; IS__TUNIT_NPM-SAME: (float [[FA:%.*]], float [[FB:%.*]], double [[DA:%.*]], double [[DB:%.*]], double* nofree readnone [[DPA:%.*]], double* nofree readnone [[DPB:%.*]], i8* nofree readnone [[IPA:%.*]], i8* nofree readnone [[IPB:%.*]]) #[[ATTR1]] {
1357; IS__TUNIT_NPM-NEXT:    [[R1:%.*]] = call i1 @f_fcmp(float [[FA]], float [[FB]]) #[[ATTR4]]
1358; IS__TUNIT_NPM-NEXT:    [[R2:%.*]] = call i1 @d_fcmp(double [[DA]], double [[DB]]) #[[ATTR4]]
1359; IS__TUNIT_NPM-NEXT:    [[R3:%.*]] = call i1 @dp_icmp(double* noalias nofree readnone [[DPA]], double* noalias nofree readnone [[DPB]]) #[[ATTR4]]
1360; IS__TUNIT_NPM-NEXT:    [[R4:%.*]] = call i1 @ip_icmp(i8* noalias nofree readnone [[IPA]], i8* noalias nofree readnone [[IPB]]) #[[ATTR4]]
1361; IS__TUNIT_NPM-NEXT:    [[O1:%.*]] = or i1 [[R1]], [[R2]]
1362; IS__TUNIT_NPM-NEXT:    [[O2:%.*]] = or i1 [[R3]], [[R4]]
1363; IS__TUNIT_NPM-NEXT:    [[O3:%.*]] = or i1 [[O1]], [[O2]]
1364; IS__TUNIT_NPM-NEXT:    ret i1 [[O3]]
1365;
1366; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
1367; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@fcmp_caller
1368; IS__CGSCC_OPM-SAME: (float [[FA:%.*]], float [[FB:%.*]], double [[DA:%.*]], double [[DB:%.*]], double* nofree readnone [[DPA:%.*]], double* nofree readnone [[DPB:%.*]], i8* nofree readnone [[IPA:%.*]], i8* nofree readnone [[IPB:%.*]]) #[[ATTR4]] {
1369; IS__CGSCC_OPM-NEXT:    [[R1:%.*]] = call i1 @f_fcmp(float [[FA]], float [[FB]]) #[[ATTR7]]
1370; IS__CGSCC_OPM-NEXT:    [[R2:%.*]] = call i1 @d_fcmp(double [[DA]], double [[DB]]) #[[ATTR7]]
1371; IS__CGSCC_OPM-NEXT:    [[R3:%.*]] = call i1 @dp_icmp(double* noalias nofree readnone [[DPA]], double* noalias nofree readnone [[DPB]]) #[[ATTR7]]
1372; IS__CGSCC_OPM-NEXT:    [[R4:%.*]] = call i1 @ip_icmp(i8* noalias nofree readnone [[IPA]], i8* noalias nofree readnone [[IPB]]) #[[ATTR7]]
1373; IS__CGSCC_OPM-NEXT:    [[O1:%.*]] = or i1 [[R1]], [[R2]]
1374; IS__CGSCC_OPM-NEXT:    [[O2:%.*]] = or i1 [[R3]], [[R4]]
1375; IS__CGSCC_OPM-NEXT:    [[O3:%.*]] = or i1 [[O1]], [[O2]]
1376; IS__CGSCC_OPM-NEXT:    ret i1 [[O3]]
1377;
1378; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
1379; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@fcmp_caller
1380; IS__CGSCC_NPM-SAME: (float [[FA:%.*]], float [[FB:%.*]], double [[DA:%.*]], double [[DB:%.*]], double* nofree readnone [[DPA:%.*]], double* nofree readnone [[DPB:%.*]], i8* nofree readnone [[IPA:%.*]], i8* nofree readnone [[IPB:%.*]]) #[[ATTR3]] {
1381; IS__CGSCC_NPM-NEXT:    [[R1:%.*]] = call i1 @f_fcmp(float [[FA]], float [[FB]]) #[[ATTR6]]
1382; IS__CGSCC_NPM-NEXT:    [[R2:%.*]] = call i1 @d_fcmp(double [[DA]], double [[DB]]) #[[ATTR6]]
1383; IS__CGSCC_NPM-NEXT:    [[R3:%.*]] = call i1 @dp_icmp(double* noalias nofree readnone [[DPA]], double* noalias nofree readnone [[DPB]]) #[[ATTR6]]
1384; IS__CGSCC_NPM-NEXT:    [[R4:%.*]] = call i1 @ip_icmp(i8* noalias nofree readnone [[IPA]], i8* noalias nofree readnone [[IPB]]) #[[ATTR6]]
1385; IS__CGSCC_NPM-NEXT:    [[O1:%.*]] = or i1 [[R1]], [[R2]]
1386; IS__CGSCC_NPM-NEXT:    [[O2:%.*]] = or i1 [[R3]], [[R4]]
1387; IS__CGSCC_NPM-NEXT:    [[O3:%.*]] = or i1 [[O1]], [[O2]]
1388; IS__CGSCC_NPM-NEXT:    ret i1 [[O3]]
1389;
1390  %r1 = call i1 @f_fcmp(float %fa, float %fb)
1391  %r2 = call i1 @d_fcmp(double %da, double %db)
1392  %r3 = call i1 @dp_icmp(double* %dpa, double* %dpb)
1393  %r4 = call i1 @ip_icmp(i8* %ipa, i8* %ipb)
1394  %o1 = or i1 %r1, %r2
1395  %o2 = or i1 %r3, %r4
1396  %o3 = or i1 %o1, %o2
1397  ret i1 %o3
1398}
1399
1400define i8 @ret_two() {
1401; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1402; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@ret_two
1403; IS__TUNIT_OPM-SAME: () #[[ATTR2]] {
1404; IS__TUNIT_OPM-NEXT:    ret i8 2
1405;
1406; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1407; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@ret_two
1408; IS__TUNIT_NPM-SAME: () #[[ATTR1]] {
1409; IS__TUNIT_NPM-NEXT:    ret i8 2
1410;
1411; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1412; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@ret_two
1413; IS__CGSCC_OPM-SAME: () #[[ATTR3]] {
1414; IS__CGSCC_OPM-NEXT:    ret i8 2
1415;
1416; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1417; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@ret_two
1418; IS__CGSCC_NPM-SAME: () #[[ATTR2]] {
1419; IS__CGSCC_NPM-NEXT:    ret i8 2
1420;
1421  ret i8 2
1422}
1423define i8 @ret_undef() {
1424; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1425; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@ret_undef
1426; IS__TUNIT_OPM-SAME: () #[[ATTR2]] {
1427; IS__TUNIT_OPM-NEXT:    ret i8 undef
1428;
1429; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1430; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@ret_undef
1431; IS__TUNIT_NPM-SAME: () #[[ATTR1]] {
1432; IS__TUNIT_NPM-NEXT:    ret i8 undef
1433;
1434; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1435; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@ret_undef
1436; IS__CGSCC_OPM-SAME: () #[[ATTR3]] {
1437; IS__CGSCC_OPM-NEXT:    ret i8 undef
1438;
1439; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1440; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@ret_undef
1441; IS__CGSCC_NPM-SAME: () #[[ATTR2]] {
1442; IS__CGSCC_NPM-NEXT:    ret i8 undef
1443;
1444  ret i8 undef
1445}
1446
1447; Verify we collapse undef to a value and return something non-undef here.
1448define i8 @undef_collapse_1() {
1449; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1450; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@undef_collapse_1
1451; IS__TUNIT_OPM-SAME: () #[[ATTR2]] {
1452; IS__TUNIT_OPM-NEXT:    ret i8 0
1453;
1454; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1455; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@undef_collapse_1
1456; IS__TUNIT_NPM-SAME: () #[[ATTR1]] {
1457; IS__TUNIT_NPM-NEXT:    ret i8 0
1458;
1459; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
1460; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@undef_collapse_1
1461; IS__CGSCC_OPM-SAME: () #[[ATTR4]] {
1462; IS__CGSCC_OPM-NEXT:    [[C:%.*]] = call i8 @ret_undef() #[[ATTR7]]
1463; IS__CGSCC_OPM-NEXT:    [[S:%.*]] = shl i8 [[C]], 2
1464; IS__CGSCC_OPM-NEXT:    ret i8 [[S]]
1465;
1466; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
1467; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@undef_collapse_1
1468; IS__CGSCC_NPM-SAME: () #[[ATTR3]] {
1469; IS__CGSCC_NPM-NEXT:    [[C:%.*]] = call i8 @ret_undef() #[[ATTR6]]
1470; IS__CGSCC_NPM-NEXT:    [[S:%.*]] = shl i8 [[C]], 2
1471; IS__CGSCC_NPM-NEXT:    ret i8 [[S]]
1472;
1473  %c = call i8 @ret_undef()
1474  %s = shl i8 %c, 2
1475  ret i8 %s
1476}
1477
1478; Verify we collapse undef to a value and return something non-undef here.
1479define i8 @undef_collapse_2() {
1480; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1481; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@undef_collapse_2
1482; IS__TUNIT_OPM-SAME: () #[[ATTR2]] {
1483; IS__TUNIT_OPM-NEXT:    ret i8 0
1484;
1485; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1486; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@undef_collapse_2
1487; IS__TUNIT_NPM-SAME: () #[[ATTR1]] {
1488; IS__TUNIT_NPM-NEXT:    ret i8 0
1489;
1490; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
1491; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@undef_collapse_2
1492; IS__CGSCC_OPM-SAME: () #[[ATTR4]] {
1493; IS__CGSCC_OPM-NEXT:    [[C:%.*]] = call i8 @ret_two() #[[ATTR7]]
1494; IS__CGSCC_OPM-NEXT:    [[S:%.*]] = shl i8 undef, [[C]]
1495; IS__CGSCC_OPM-NEXT:    ret i8 [[S]]
1496;
1497; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
1498; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@undef_collapse_2
1499; IS__CGSCC_NPM-SAME: () #[[ATTR3]] {
1500; IS__CGSCC_NPM-NEXT:    [[C:%.*]] = call i8 @ret_two() #[[ATTR6]]
1501; IS__CGSCC_NPM-NEXT:    [[S:%.*]] = shl i8 undef, [[C]]
1502; IS__CGSCC_NPM-NEXT:    ret i8 [[S]]
1503;
1504  %c = call i8 @ret_two()
1505  %s = shl i8 undef, %c
1506  ret i8 %s
1507}
1508
1509define i8 @undef_collapse_caller() {
1510;
1511; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1512; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@undef_collapse_caller
1513; IS__TUNIT_OPM-SAME: () #[[ATTR2]] {
1514; IS__TUNIT_OPM-NEXT:    ret i8 0
1515;
1516; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1517; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@undef_collapse_caller
1518; IS__TUNIT_NPM-SAME: () #[[ATTR1]] {
1519; IS__TUNIT_NPM-NEXT:    ret i8 0
1520;
1521; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
1522; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@undef_collapse_caller
1523; IS__CGSCC_OPM-SAME: () #[[ATTR4]] {
1524; IS__CGSCC_OPM-NEXT:    [[C1:%.*]] = call i8 @undef_collapse_1() #[[ATTR7]]
1525; IS__CGSCC_OPM-NEXT:    [[C2:%.*]] = call i8 @undef_collapse_2() #[[ATTR7]]
1526; IS__CGSCC_OPM-NEXT:    [[A:%.*]] = add i8 [[C1]], [[C2]]
1527; IS__CGSCC_OPM-NEXT:    ret i8 [[A]]
1528;
1529; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
1530; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@undef_collapse_caller
1531; IS__CGSCC_NPM-SAME: () #[[ATTR3]] {
1532; IS__CGSCC_NPM-NEXT:    [[C1:%.*]] = call i8 @undef_collapse_1() #[[ATTR6]]
1533; IS__CGSCC_NPM-NEXT:    [[C2:%.*]] = call i8 @undef_collapse_2() #[[ATTR6]]
1534; IS__CGSCC_NPM-NEXT:    [[A:%.*]] = add i8 [[C1]], [[C2]]
1535; IS__CGSCC_NPM-NEXT:    ret i8 [[A]]
1536;
1537  %c1 = call i8 @undef_collapse_1()
1538  %c2 = call i8 @undef_collapse_2()
1539  %a = add i8 %c1, %c2
1540  ret i8 %a
1541}
1542
1543define i32 @ret1or2(i1 %c) {
1544; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1545; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@ret1or2
1546; IS__TUNIT_OPM-SAME: (i1 [[C:%.*]]) #[[ATTR2]] {
1547; IS__TUNIT_OPM-NEXT:    [[S:%.*]] = select i1 [[C]], i32 1, i32 2
1548; IS__TUNIT_OPM-NEXT:    ret i32 [[S]]
1549;
1550; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1551; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@ret1or2
1552; IS__TUNIT_NPM-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
1553; IS__TUNIT_NPM-NEXT:    [[S:%.*]] = select i1 [[C]], i32 1, i32 2
1554; IS__TUNIT_NPM-NEXT:    ret i32 [[S]]
1555;
1556; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1557; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@ret1or2
1558; IS__CGSCC_OPM-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
1559; IS__CGSCC_OPM-NEXT:    [[S:%.*]] = select i1 [[C]], i32 1, i32 2
1560; IS__CGSCC_OPM-NEXT:    ret i32 [[S]]
1561;
1562; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1563; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@ret1or2
1564; IS__CGSCC_NPM-SAME: (i1 [[C:%.*]]) #[[ATTR2]] {
1565; IS__CGSCC_NPM-NEXT:    [[S:%.*]] = select i1 [[C]], i32 1, i32 2
1566; IS__CGSCC_NPM-NEXT:    ret i32 [[S]]
1567;
1568  %s = select i1 %c, i32 1, i32 2
1569  ret i32 %s
1570}
1571define i1 @callee_range_1(i1 %c1, i1 %c2, i1 %c3) {
1572;
1573; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1574; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@callee_range_1
1575; IS__TUNIT_OPM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]]) #[[ATTR2]] {
1576; IS__TUNIT_OPM-NEXT:    [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) #[[ATTR5]]
1577; IS__TUNIT_OPM-NEXT:    [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) #[[ATTR5]]
1578; IS__TUNIT_OPM-NEXT:    [[INDIRECTION:%.*]] = select i1 [[C3]], i32 [[R1]], i32 [[R2]]
1579; IS__TUNIT_OPM-NEXT:    [[A:%.*]] = add i32 [[R1]], [[INDIRECTION]]
1580; IS__TUNIT_OPM-NEXT:    [[I1:%.*]] = icmp sle i32 [[A]], 4
1581; IS__TUNIT_OPM-NEXT:    [[I2:%.*]] = icmp sge i32 [[A]], 2
1582; IS__TUNIT_OPM-NEXT:    [[F:%.*]] = and i1 [[I1]], [[I2]]
1583; IS__TUNIT_OPM-NEXT:    ret i1 [[F]]
1584;
1585; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1586; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@callee_range_1
1587; IS__TUNIT_NPM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]]) #[[ATTR1]] {
1588; IS__TUNIT_NPM-NEXT:    [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) #[[ATTR4]]
1589; IS__TUNIT_NPM-NEXT:    [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) #[[ATTR4]]
1590; IS__TUNIT_NPM-NEXT:    [[INDIRECTION:%.*]] = select i1 [[C3]], i32 [[R1]], i32 [[R2]]
1591; IS__TUNIT_NPM-NEXT:    [[A:%.*]] = add i32 [[R1]], [[INDIRECTION]]
1592; IS__TUNIT_NPM-NEXT:    [[I1:%.*]] = icmp sle i32 [[A]], 4
1593; IS__TUNIT_NPM-NEXT:    [[I2:%.*]] = icmp sge i32 [[A]], 2
1594; IS__TUNIT_NPM-NEXT:    [[F:%.*]] = and i1 [[I1]], [[I2]]
1595; IS__TUNIT_NPM-NEXT:    ret i1 [[F]]
1596;
1597; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
1598; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@callee_range_1
1599; IS__CGSCC_OPM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]]) #[[ATTR4]] {
1600; IS__CGSCC_OPM-NEXT:    [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) #[[ATTR7]]
1601; IS__CGSCC_OPM-NEXT:    [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) #[[ATTR7]]
1602; IS__CGSCC_OPM-NEXT:    [[INDIRECTION:%.*]] = select i1 [[C3]], i32 [[R1]], i32 [[R2]]
1603; IS__CGSCC_OPM-NEXT:    [[A:%.*]] = add i32 [[R1]], [[INDIRECTION]]
1604; IS__CGSCC_OPM-NEXT:    [[I1:%.*]] = icmp sle i32 [[A]], 4
1605; IS__CGSCC_OPM-NEXT:    [[I2:%.*]] = icmp sge i32 [[A]], 2
1606; IS__CGSCC_OPM-NEXT:    [[F:%.*]] = and i1 [[I1]], [[I2]]
1607; IS__CGSCC_OPM-NEXT:    ret i1 [[F]]
1608;
1609; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
1610; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@callee_range_1
1611; IS__CGSCC_NPM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]]) #[[ATTR3]] {
1612; IS__CGSCC_NPM-NEXT:    [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) #[[ATTR6]]
1613; IS__CGSCC_NPM-NEXT:    [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) #[[ATTR6]]
1614; IS__CGSCC_NPM-NEXT:    [[INDIRECTION:%.*]] = select i1 [[C3]], i32 [[R1]], i32 [[R2]]
1615; IS__CGSCC_NPM-NEXT:    [[A:%.*]] = add i32 [[R1]], [[INDIRECTION]]
1616; IS__CGSCC_NPM-NEXT:    [[I1:%.*]] = icmp sle i32 [[A]], 4
1617; IS__CGSCC_NPM-NEXT:    [[I2:%.*]] = icmp sge i32 [[A]], 2
1618; IS__CGSCC_NPM-NEXT:    [[F:%.*]] = and i1 [[I1]], [[I2]]
1619; IS__CGSCC_NPM-NEXT:    ret i1 [[F]]
1620;
1621  %r1 = call i32 @ret1or2(i1 %c1)
1622  %r2 = call i32 @ret1or2(i1 %c2)
1623  %indirection = select i1 %c3, i32 %r1, i32 %r2
1624  %a = add i32 %r1, %indirection
1625  %i1 = icmp sle i32 %a, 4
1626  %i2 = icmp sge i32 %a, 2
1627  %f = and i1 %i1, %i2
1628  ret i1 %f
1629}
1630
1631define i1 @callee_range_2(i1 %c1, i1 %c2) {
1632;
1633; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1634; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@callee_range_2
1635; IS__TUNIT_OPM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]]) #[[ATTR2]] {
1636; IS__TUNIT_OPM-NEXT:    [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) #[[ATTR5]]
1637; IS__TUNIT_OPM-NEXT:    [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) #[[ATTR5]]
1638; IS__TUNIT_OPM-NEXT:    [[A:%.*]] = add i32 [[R1]], [[R2]]
1639; IS__TUNIT_OPM-NEXT:    [[I1:%.*]] = icmp sle i32 [[A]], 3
1640; IS__TUNIT_OPM-NEXT:    [[I2:%.*]] = icmp sge i32 [[A]], 2
1641; IS__TUNIT_OPM-NEXT:    [[F:%.*]] = and i1 [[I1]], [[I2]]
1642; IS__TUNIT_OPM-NEXT:    ret i1 [[F]]
1643;
1644; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1645; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@callee_range_2
1646; IS__TUNIT_NPM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]]) #[[ATTR1]] {
1647; IS__TUNIT_NPM-NEXT:    [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) #[[ATTR4]]
1648; IS__TUNIT_NPM-NEXT:    [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) #[[ATTR4]]
1649; IS__TUNIT_NPM-NEXT:    [[A:%.*]] = add i32 [[R1]], [[R2]]
1650; IS__TUNIT_NPM-NEXT:    [[I1:%.*]] = icmp sle i32 [[A]], 3
1651; IS__TUNIT_NPM-NEXT:    [[I2:%.*]] = icmp sge i32 [[A]], 2
1652; IS__TUNIT_NPM-NEXT:    [[F:%.*]] = and i1 [[I1]], [[I2]]
1653; IS__TUNIT_NPM-NEXT:    ret i1 [[F]]
1654;
1655; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
1656; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@callee_range_2
1657; IS__CGSCC_OPM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]]) #[[ATTR4]] {
1658; IS__CGSCC_OPM-NEXT:    [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) #[[ATTR7]]
1659; IS__CGSCC_OPM-NEXT:    [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) #[[ATTR7]]
1660; IS__CGSCC_OPM-NEXT:    [[A:%.*]] = add i32 [[R1]], [[R2]]
1661; IS__CGSCC_OPM-NEXT:    [[I1:%.*]] = icmp sle i32 [[A]], 3
1662; IS__CGSCC_OPM-NEXT:    [[I2:%.*]] = icmp sge i32 [[A]], 2
1663; IS__CGSCC_OPM-NEXT:    [[F:%.*]] = and i1 [[I1]], [[I2]]
1664; IS__CGSCC_OPM-NEXT:    ret i1 [[F]]
1665;
1666; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
1667; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@callee_range_2
1668; IS__CGSCC_NPM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]]) #[[ATTR3]] {
1669; IS__CGSCC_NPM-NEXT:    [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) #[[ATTR6]]
1670; IS__CGSCC_NPM-NEXT:    [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) #[[ATTR6]]
1671; IS__CGSCC_NPM-NEXT:    [[A:%.*]] = add i32 [[R1]], [[R2]]
1672; IS__CGSCC_NPM-NEXT:    [[I1:%.*]] = icmp sle i32 [[A]], 3
1673; IS__CGSCC_NPM-NEXT:    [[I2:%.*]] = icmp sge i32 [[A]], 2
1674; IS__CGSCC_NPM-NEXT:    [[F:%.*]] = and i1 [[I1]], [[I2]]
1675; IS__CGSCC_NPM-NEXT:    ret i1 [[F]]
1676;
1677  %r1 = call i32 @ret1or2(i1 %c1)
1678  %r2 = call i32 @ret1or2(i1 %c2)
1679  %a = add i32 %r1, %r2
1680  %i1 = icmp sle i32 %a, 3
1681  %i2 = icmp sge i32 %a, 2
1682  %f = and i1 %i1, %i2
1683  ret i1 %f
1684}
1685
1686
1687define i32 @ret100() {
1688; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1689; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@ret100
1690; IS__TUNIT_OPM-SAME: () #[[ATTR2]] {
1691; IS__TUNIT_OPM-NEXT:    ret i32 100
1692;
1693; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1694; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@ret100
1695; IS__TUNIT_NPM-SAME: () #[[ATTR1]] {
1696; IS__TUNIT_NPM-NEXT:    ret i32 100
1697;
1698; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1699; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@ret100
1700; IS__CGSCC_OPM-SAME: () #[[ATTR3]] {
1701; IS__CGSCC_OPM-NEXT:    ret i32 100
1702;
1703; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1704; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@ret100
1705; IS__CGSCC_NPM-SAME: () #[[ATTR2]] {
1706; IS__CGSCC_NPM-NEXT:    ret i32 100
1707;
1708  ret i32 100
1709}
1710
1711define i1 @ctx_adjustment(i32 %V) {
1712;
1713; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1714; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@ctx_adjustment
1715; IS__TUNIT_OPM-SAME: (i32 [[V:%.*]]) #[[ATTR2]] {
1716; IS__TUNIT_OPM-NEXT:    [[C1:%.*]] = icmp sge i32 [[V]], 100
1717; IS__TUNIT_OPM-NEXT:    br i1 [[C1]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
1718; IS__TUNIT_OPM:       if.true:
1719; IS__TUNIT_OPM-NEXT:    br label [[END:%.*]]
1720; IS__TUNIT_OPM:       if.false:
1721; IS__TUNIT_OPM-NEXT:    br label [[END]]
1722; IS__TUNIT_OPM:       end:
1723; IS__TUNIT_OPM-NEXT:    [[PHI:%.*]] = phi i32 [ [[V]], [[IF_TRUE]] ], [ 100, [[IF_FALSE]] ]
1724; IS__TUNIT_OPM-NEXT:    [[C2:%.*]] = icmp sge i32 [[PHI]], 100
1725; IS__TUNIT_OPM-NEXT:    ret i1 [[C2]]
1726;
1727; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1728; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@ctx_adjustment
1729; IS__TUNIT_NPM-SAME: (i32 [[V:%.*]]) #[[ATTR1]] {
1730; IS__TUNIT_NPM-NEXT:    [[C1:%.*]] = icmp sge i32 [[V]], 100
1731; IS__TUNIT_NPM-NEXT:    br i1 [[C1]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
1732; IS__TUNIT_NPM:       if.true:
1733; IS__TUNIT_NPM-NEXT:    br label [[END:%.*]]
1734; IS__TUNIT_NPM:       if.false:
1735; IS__TUNIT_NPM-NEXT:    br label [[END]]
1736; IS__TUNIT_NPM:       end:
1737; IS__TUNIT_NPM-NEXT:    [[PHI:%.*]] = phi i32 [ [[V]], [[IF_TRUE]] ], [ 100, [[IF_FALSE]] ]
1738; IS__TUNIT_NPM-NEXT:    [[C2:%.*]] = icmp sge i32 [[PHI]], 100
1739; IS__TUNIT_NPM-NEXT:    ret i1 [[C2]]
1740;
1741; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
1742; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@ctx_adjustment
1743; IS__CGSCC_OPM-SAME: (i32 [[V:%.*]]) #[[ATTR4]] {
1744; IS__CGSCC_OPM-NEXT:    [[C1:%.*]] = icmp sge i32 [[V]], 100
1745; IS__CGSCC_OPM-NEXT:    br i1 [[C1]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
1746; IS__CGSCC_OPM:       if.true:
1747; IS__CGSCC_OPM-NEXT:    br label [[END:%.*]]
1748; IS__CGSCC_OPM:       if.false:
1749; IS__CGSCC_OPM-NEXT:    [[CALL:%.*]] = call i32 @ret100() #[[ATTR7]]
1750; IS__CGSCC_OPM-NEXT:    br label [[END]]
1751; IS__CGSCC_OPM:       end:
1752; IS__CGSCC_OPM-NEXT:    [[PHI:%.*]] = phi i32 [ [[V]], [[IF_TRUE]] ], [ [[CALL]], [[IF_FALSE]] ]
1753; IS__CGSCC_OPM-NEXT:    [[C2:%.*]] = icmp sge i32 [[PHI]], 100
1754; IS__CGSCC_OPM-NEXT:    ret i1 [[C2]]
1755;
1756; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
1757; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@ctx_adjustment
1758; IS__CGSCC_NPM-SAME: (i32 [[V:%.*]]) #[[ATTR3]] {
1759; IS__CGSCC_NPM-NEXT:    [[C1:%.*]] = icmp sge i32 [[V]], 100
1760; IS__CGSCC_NPM-NEXT:    br i1 [[C1]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
1761; IS__CGSCC_NPM:       if.true:
1762; IS__CGSCC_NPM-NEXT:    br label [[END:%.*]]
1763; IS__CGSCC_NPM:       if.false:
1764; IS__CGSCC_NPM-NEXT:    [[CALL:%.*]] = call i32 @ret100() #[[ATTR6]]
1765; IS__CGSCC_NPM-NEXT:    br label [[END]]
1766; IS__CGSCC_NPM:       end:
1767; IS__CGSCC_NPM-NEXT:    [[PHI:%.*]] = phi i32 [ [[V]], [[IF_TRUE]] ], [ [[CALL]], [[IF_FALSE]] ]
1768; IS__CGSCC_NPM-NEXT:    [[C2:%.*]] = icmp sge i32 [[PHI]], 100
1769; IS__CGSCC_NPM-NEXT:    ret i1 [[C2]]
1770;
1771  %c1 = icmp sge i32 %V, 100
1772  br i1 %c1, label %if.true, label %if.false
1773if.true:
1774  br label %end
1775if.false:
1776  %call = call i32 @ret100()
1777  br label %end
1778end:
1779  %phi = phi i32 [ %V, %if.true ], [ %call, %if.false ]
1780  %c2 = icmp sge i32 %phi, 100
1781  ret i1 %c2
1782}
1783
1784
1785define i32 @func(i1 %c) {
1786; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1787; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@func
1788; IS__TUNIT_OPM-SAME: (i1 [[C:%.*]]) #[[ATTR2]] {
1789; IS__TUNIT_OPM-NEXT:    [[RET:%.*]] = select i1 [[C]], i32 0, i32 1
1790; IS__TUNIT_OPM-NEXT:    ret i32 [[RET]]
1791;
1792; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1793; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@func
1794; IS__TUNIT_NPM-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
1795; IS__TUNIT_NPM-NEXT:    [[RET:%.*]] = select i1 [[C]], i32 0, i32 1
1796; IS__TUNIT_NPM-NEXT:    ret i32 [[RET]]
1797;
1798; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1799; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@func
1800; IS__CGSCC_OPM-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
1801; IS__CGSCC_OPM-NEXT:    [[RET:%.*]] = select i1 [[C]], i32 0, i32 1
1802; IS__CGSCC_OPM-NEXT:    ret i32 [[RET]]
1803;
1804; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1805; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@func
1806; IS__CGSCC_NPM-SAME: (i1 [[C:%.*]]) #[[ATTR2]] {
1807; IS__CGSCC_NPM-NEXT:    [[RET:%.*]] = select i1 [[C]], i32 0, i32 1
1808; IS__CGSCC_NPM-NEXT:    ret i32 [[RET]]
1809;
1810  %ret = select i1 %c, i32 0, i32 1
1811  ret i32 %ret
1812}
1813
1814define i32 @simplify_callsite_argument(i1 %d) {
1815; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1816; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@simplify_callsite_argument
1817; IS__TUNIT_OPM-SAME: (i1 [[D:%.*]]) #[[ATTR2]] {
1818; IS__TUNIT_OPM-NEXT:    [[C:%.*]] = select i1 [[D]], i1 true, i1 false
1819; IS__TUNIT_OPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
1820; IS__TUNIT_OPM:       t:
1821; IS__TUNIT_OPM-NEXT:    [[RET1:%.*]] = call i32 @func(i1 noundef [[C]]) #[[ATTR5]]
1822; IS__TUNIT_OPM-NEXT:    ret i32 [[RET1]]
1823; IS__TUNIT_OPM:       f:
1824; IS__TUNIT_OPM-NEXT:    [[RET2:%.*]] = call i32 @func(i1 noundef false) #[[ATTR5]]
1825; IS__TUNIT_OPM-NEXT:    ret i32 [[RET2]]
1826;
1827; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1828; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@simplify_callsite_argument
1829; IS__TUNIT_NPM-SAME: (i1 [[D:%.*]]) #[[ATTR1]] {
1830; IS__TUNIT_NPM-NEXT:    [[C:%.*]] = select i1 [[D]], i1 true, i1 false
1831; IS__TUNIT_NPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
1832; IS__TUNIT_NPM:       t:
1833; IS__TUNIT_NPM-NEXT:    [[RET1:%.*]] = call i32 @func(i1 noundef [[C]]) #[[ATTR4]]
1834; IS__TUNIT_NPM-NEXT:    ret i32 [[RET1]]
1835; IS__TUNIT_NPM:       f:
1836; IS__TUNIT_NPM-NEXT:    [[RET2:%.*]] = call i32 @func(i1 noundef false) #[[ATTR4]]
1837; IS__TUNIT_NPM-NEXT:    ret i32 [[RET2]]
1838;
1839; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
1840; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@simplify_callsite_argument
1841; IS__CGSCC_OPM-SAME: (i1 [[D:%.*]]) #[[ATTR4]] {
1842; IS__CGSCC_OPM-NEXT:    [[C:%.*]] = select i1 [[D]], i1 true, i1 false
1843; IS__CGSCC_OPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
1844; IS__CGSCC_OPM:       t:
1845; IS__CGSCC_OPM-NEXT:    [[RET1:%.*]] = call noundef i32 @func(i1 noundef [[C]]) #[[ATTR7]]
1846; IS__CGSCC_OPM-NEXT:    ret i32 [[RET1]]
1847; IS__CGSCC_OPM:       f:
1848; IS__CGSCC_OPM-NEXT:    [[RET2:%.*]] = call noundef i32 @func(i1 noundef false) #[[ATTR7]]
1849; IS__CGSCC_OPM-NEXT:    ret i32 [[RET2]]
1850;
1851; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
1852; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@simplify_callsite_argument
1853; IS__CGSCC_NPM-SAME: (i1 [[D:%.*]]) #[[ATTR3]] {
1854; IS__CGSCC_NPM-NEXT:    [[C:%.*]] = select i1 [[D]], i1 true, i1 false
1855; IS__CGSCC_NPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
1856; IS__CGSCC_NPM:       t:
1857; IS__CGSCC_NPM-NEXT:    [[RET1:%.*]] = call noundef i32 @func(i1 noundef [[C]]) #[[ATTR6]]
1858; IS__CGSCC_NPM-NEXT:    ret i32 [[RET1]]
1859; IS__CGSCC_NPM:       f:
1860; IS__CGSCC_NPM-NEXT:    [[RET2:%.*]] = call noundef i32 @func(i1 noundef false) #[[ATTR6]]
1861; IS__CGSCC_NPM-NEXT:    ret i32 [[RET2]]
1862;
1863  %c = select i1 %d, i1 true, i1 false
1864  br i1 %c, label %t, label %f
1865t:
1866  %ret1 = call i32 @func(i1 %c)
1867  ret i32 %ret1
1868f:
1869  %ret2 = call i32 @func(i1 false)
1870  ret i32 %ret2
1871}
1872
1873define internal i32 @less_than_65536(i32 %arg) {
1874;
1875; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1876; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@less_than_65536
1877; IS__CGSCC_OPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR3]] {
1878; IS__CGSCC_OPM-NEXT:    [[SHRINKED:%.*]] = udiv i32 [[ARG]], 65536
1879; IS__CGSCC_OPM-NEXT:    ret i32 [[SHRINKED]]
1880;
1881; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1882; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@less_than_65536
1883; IS__CGSCC_NPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR2]] {
1884; IS__CGSCC_NPM-NEXT:    [[SHRINKED:%.*]] = udiv i32 [[ARG]], 65536
1885; IS__CGSCC_NPM-NEXT:    ret i32 [[SHRINKED]]
1886;
1887  %shrinked = udiv i32 %arg, 65536
1888  ret i32 %shrinked
1889}
1890
1891define internal i1 @is_less_than_65536(i32 %arg) {
1892; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1893; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@is_less_than_65536
1894; IS__CGSCC_OPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR3]] {
1895; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp ult i32 [[ARG]], 65536
1896; IS__CGSCC_OPM-NEXT:    ret i1 [[CMP]]
1897;
1898; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1899; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@is_less_than_65536
1900; IS__CGSCC_NPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR2]] {
1901; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp ult i32 [[ARG]], 65536
1902; IS__CGSCC_NPM-NEXT:    ret i1 [[CMP]]
1903;
1904  %cmp = icmp ult i32 %arg, 65536
1905  ret i1 %cmp
1906}
1907
1908define i1 @check_divided_range(i32 %arg) {
1909; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1910; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@check_divided_range
1911; IS__TUNIT_OPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR2]] {
1912; IS__TUNIT_OPM-NEXT:    ret i1 true
1913;
1914; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1915; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@check_divided_range
1916; IS__TUNIT_NPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR1]] {
1917; IS__TUNIT_NPM-NEXT:    ret i1 true
1918;
1919; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
1920; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@check_divided_range
1921; IS__CGSCC_OPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR4]] {
1922; IS__CGSCC_OPM-NEXT:    [[CSRET1:%.*]] = call i32 @less_than_65536(i32 noundef 0) #[[ATTR7]]
1923; IS__CGSCC_OPM-NEXT:    [[CSRET2:%.*]] = call i32 @less_than_65536(i32 [[ARG]]) #[[ATTR7]]
1924; IS__CGSCC_OPM-NEXT:    [[TRUE1:%.*]] = call i1 @is_less_than_65536(i32 [[CSRET1]]) #[[ATTR7]]
1925; IS__CGSCC_OPM-NEXT:    [[TRUE2:%.*]] = call i1 @is_less_than_65536(i32 [[CSRET2]]) #[[ATTR7]]
1926; IS__CGSCC_OPM-NEXT:    [[RET:%.*]] = and i1 [[TRUE1]], [[TRUE2]]
1927; IS__CGSCC_OPM-NEXT:    ret i1 [[RET]]
1928;
1929; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
1930; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@check_divided_range
1931; IS__CGSCC_NPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR3]] {
1932; IS__CGSCC_NPM-NEXT:    [[CSRET1:%.*]] = call i32 @less_than_65536(i32 noundef 0) #[[ATTR6]]
1933; IS__CGSCC_NPM-NEXT:    [[CSRET2:%.*]] = call i32 @less_than_65536(i32 [[ARG]]) #[[ATTR6]]
1934; IS__CGSCC_NPM-NEXT:    [[TRUE1:%.*]] = call i1 @is_less_than_65536(i32 [[CSRET1]]) #[[ATTR6]]
1935; IS__CGSCC_NPM-NEXT:    [[TRUE2:%.*]] = call i1 @is_less_than_65536(i32 [[CSRET2]]) #[[ATTR6]]
1936; IS__CGSCC_NPM-NEXT:    [[RET:%.*]] = and i1 [[TRUE1]], [[TRUE2]]
1937; IS__CGSCC_NPM-NEXT:    ret i1 [[RET]]
1938;
1939  %csret1 = call i32 @less_than_65536(i32 0)
1940  %csret2 = call i32 @less_than_65536(i32 %arg)
1941  %true1 = call i1 @is_less_than_65536(i32 %csret1)
1942  %true2 = call i1 @is_less_than_65536(i32 %csret2)
1943  %ret = and i1 %true1, %true2
1944  ret i1 %ret
1945}
1946
1947define internal i32 @cast_and_return(i1 %c) {
1948;
1949; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1950; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@cast_and_return
1951; IS__CGSCC_OPM-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
1952; IS__CGSCC_OPM-NEXT:    [[RET:%.*]] = zext i1 [[C]] to i32
1953; IS__CGSCC_OPM-NEXT:    ret i32 [[RET]]
1954;
1955; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1956; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@cast_and_return
1957; IS__CGSCC_NPM-SAME: (i1 [[C:%.*]]) #[[ATTR2]] {
1958; IS__CGSCC_NPM-NEXT:    [[RET:%.*]] = zext i1 [[C]] to i32
1959; IS__CGSCC_NPM-NEXT:    ret i32 [[RET]]
1960;
1961  %ret = zext i1 %c to i32
1962  ret i32 %ret
1963}
1964
1965define internal i1 @is_less_than_3(i32 %c) {
1966; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1967; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@is_less_than_3
1968; IS__CGSCC_OPM-SAME: (i32 [[C:%.*]]) #[[ATTR3]] {
1969; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[C]], 3
1970; IS__CGSCC_OPM-NEXT:    ret i1 [[CMP]]
1971;
1972; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1973; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@is_less_than_3
1974; IS__CGSCC_NPM-SAME: (i32 [[C:%.*]]) #[[ATTR2]] {
1975; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[C]], 3
1976; IS__CGSCC_NPM-NEXT:    ret i1 [[CMP]]
1977;
1978  %cmp = icmp slt i32 %c, 3
1979  ret i1 %cmp
1980}
1981
1982define i1 @check_casted_range(i1 %c) {
1983; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1984; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@check_casted_range
1985; IS__TUNIT_OPM-SAME: (i1 [[C:%.*]]) #[[ATTR2]] {
1986; IS__TUNIT_OPM-NEXT:    ret i1 true
1987;
1988; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1989; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@check_casted_range
1990; IS__TUNIT_NPM-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
1991; IS__TUNIT_NPM-NEXT:    ret i1 true
1992;
1993; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
1994; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@check_casted_range
1995; IS__CGSCC_OPM-SAME: (i1 [[C:%.*]]) #[[ATTR4]] {
1996; IS__CGSCC_OPM-NEXT:    [[CSRET1:%.*]] = call i32 @cast_and_return(i1 noundef true) #[[ATTR7]]
1997; IS__CGSCC_OPM-NEXT:    [[CSRET2:%.*]] = call i32 @cast_and_return(i1 [[C]]) #[[ATTR7]]
1998; IS__CGSCC_OPM-NEXT:    [[ADD:%.*]] = add i32 [[CSRET1]], [[CSRET2]]
1999; IS__CGSCC_OPM-NEXT:    [[RET:%.*]] = call i1 @is_less_than_3(i32 [[ADD]]) #[[ATTR7]]
2000; IS__CGSCC_OPM-NEXT:    ret i1 [[RET]]
2001;
2002; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
2003; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@check_casted_range
2004; IS__CGSCC_NPM-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
2005; IS__CGSCC_NPM-NEXT:    [[CSRET1:%.*]] = call i32 @cast_and_return(i1 noundef true) #[[ATTR6]]
2006; IS__CGSCC_NPM-NEXT:    [[CSRET2:%.*]] = call i32 @cast_and_return(i1 [[C]]) #[[ATTR6]]
2007; IS__CGSCC_NPM-NEXT:    [[ADD:%.*]] = add i32 [[CSRET1]], [[CSRET2]]
2008; IS__CGSCC_NPM-NEXT:    [[RET:%.*]] = call i1 @is_less_than_3(i32 [[ADD]]) #[[ATTR6]]
2009; IS__CGSCC_NPM-NEXT:    ret i1 [[RET]]
2010;
2011  %csret1 = call i32 @cast_and_return(i1 true)
2012  %csret2 = call i32 @cast_and_return(i1 %c)
2013  %add = add i32 %csret1, %csret2
2014  %ret = call i1 @is_less_than_3(i32 %add)
2015  ret i1 %ret
2016}
2017
2018define internal i32 @less_than_100_1(i32 %c) {
2019; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2020; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@less_than_100_1
2021; IS__CGSCC_OPM-SAME: (i32 [[C:%.*]]) #[[ATTR3]] {
2022; IS__CGSCC_OPM-NEXT:    switch i32 [[C]], label [[OTHERWISE:%.*]] [
2023; IS__CGSCC_OPM-NEXT:    i32 0, label [[ONZERO:%.*]]
2024; IS__CGSCC_OPM-NEXT:    i32 1, label [[ONONE:%.*]]
2025; IS__CGSCC_OPM-NEXT:    i32 2, label [[ONTWO:%.*]]
2026; IS__CGSCC_OPM-NEXT:    i32 3, label [[ONTHREE:%.*]]
2027; IS__CGSCC_OPM-NEXT:    i32 4, label [[ONFOUR:%.*]]
2028; IS__CGSCC_OPM-NEXT:    i32 5, label [[ONFIVE:%.*]]
2029; IS__CGSCC_OPM-NEXT:    i32 6, label [[ONSIX:%.*]]
2030; IS__CGSCC_OPM-NEXT:    ]
2031; IS__CGSCC_OPM:       onzero:
2032; IS__CGSCC_OPM-NEXT:    ret i32 0
2033; IS__CGSCC_OPM:       onone:
2034; IS__CGSCC_OPM-NEXT:    ret i32 1
2035; IS__CGSCC_OPM:       ontwo:
2036; IS__CGSCC_OPM-NEXT:    ret i32 2
2037; IS__CGSCC_OPM:       onthree:
2038; IS__CGSCC_OPM-NEXT:    ret i32 3
2039; IS__CGSCC_OPM:       onfour:
2040; IS__CGSCC_OPM-NEXT:    ret i32 4
2041; IS__CGSCC_OPM:       onfive:
2042; IS__CGSCC_OPM-NEXT:    ret i32 5
2043; IS__CGSCC_OPM:       onsix:
2044; IS__CGSCC_OPM-NEXT:    ret i32 6
2045; IS__CGSCC_OPM:       otherwise:
2046; IS__CGSCC_OPM-NEXT:    ret i32 99
2047;
2048; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2049; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@less_than_100_1
2050; IS__CGSCC_NPM-SAME: (i32 [[C:%.*]]) #[[ATTR2]] {
2051; IS__CGSCC_NPM-NEXT:    switch i32 [[C]], label [[OTHERWISE:%.*]] [
2052; IS__CGSCC_NPM-NEXT:    i32 0, label [[ONZERO:%.*]]
2053; IS__CGSCC_NPM-NEXT:    i32 1, label [[ONONE:%.*]]
2054; IS__CGSCC_NPM-NEXT:    i32 2, label [[ONTWO:%.*]]
2055; IS__CGSCC_NPM-NEXT:    i32 3, label [[ONTHREE:%.*]]
2056; IS__CGSCC_NPM-NEXT:    i32 4, label [[ONFOUR:%.*]]
2057; IS__CGSCC_NPM-NEXT:    i32 5, label [[ONFIVE:%.*]]
2058; IS__CGSCC_NPM-NEXT:    i32 6, label [[ONSIX:%.*]]
2059; IS__CGSCC_NPM-NEXT:    ]
2060; IS__CGSCC_NPM:       onzero:
2061; IS__CGSCC_NPM-NEXT:    ret i32 0
2062; IS__CGSCC_NPM:       onone:
2063; IS__CGSCC_NPM-NEXT:    ret i32 1
2064; IS__CGSCC_NPM:       ontwo:
2065; IS__CGSCC_NPM-NEXT:    ret i32 2
2066; IS__CGSCC_NPM:       onthree:
2067; IS__CGSCC_NPM-NEXT:    ret i32 3
2068; IS__CGSCC_NPM:       onfour:
2069; IS__CGSCC_NPM-NEXT:    ret i32 4
2070; IS__CGSCC_NPM:       onfive:
2071; IS__CGSCC_NPM-NEXT:    ret i32 5
2072; IS__CGSCC_NPM:       onsix:
2073; IS__CGSCC_NPM-NEXT:    ret i32 6
2074; IS__CGSCC_NPM:       otherwise:
2075; IS__CGSCC_NPM-NEXT:    ret i32 99
2076;
2077  switch i32 %c, label %otherwise [ i32 0, label %onzero
2078  i32 1, label %onone
2079  i32 2, label %ontwo
2080  i32 3, label %onthree
2081  i32 4, label %onfour
2082  i32 5, label %onfive
2083  i32 6, label %onsix]
2084onzero:
2085  ret i32 0
2086onone:
2087  ret i32 1
2088ontwo:
2089  ret i32 2
2090onthree:
2091  ret i32 3
2092onfour:
2093  ret i32 4
2094onfive:
2095  ret i32 5
2096onsix:
2097  ret i32 6
2098otherwise:
2099  ret i32 99
2100}
2101
2102define internal i1 @is_less_than_100_1(i32 %c) {
2103; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2104; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@is_less_than_100_1
2105; IS__CGSCC_OPM-SAME: (i32 noundef [[C:%.*]]) #[[ATTR3]] {
2106; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[C]], 100
2107; IS__CGSCC_OPM-NEXT:    ret i1 [[CMP]]
2108;
2109; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2110; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@is_less_than_100_1
2111; IS__CGSCC_NPM-SAME: (i32 noundef [[C:%.*]]) #[[ATTR2]] {
2112; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[C]], 100
2113; IS__CGSCC_NPM-NEXT:    ret i1 [[CMP]]
2114;
2115  %cmp = icmp slt i32 %c, 100
2116  ret i1 %cmp
2117}
2118
2119define i1 @propagate_range1(i32 %c){
2120; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2121; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@propagate_range1
2122; IS__TUNIT_OPM-SAME: (i32 [[C:%.*]]) #[[ATTR2]] {
2123; IS__TUNIT_OPM-NEXT:    ret i1 true
2124;
2125; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2126; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@propagate_range1
2127; IS__TUNIT_NPM-SAME: (i32 [[C:%.*]]) #[[ATTR1]] {
2128; IS__TUNIT_NPM-NEXT:    ret i1 true
2129;
2130; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
2131; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@propagate_range1
2132; IS__CGSCC_OPM-SAME: (i32 [[C:%.*]]) #[[ATTR4]] {
2133; IS__CGSCC_OPM-NEXT:    [[CSRET:%.*]] = call i32 @less_than_100_1(i32 [[C]]) #[[ATTR7]]
2134; IS__CGSCC_OPM-NEXT:    [[TRUE:%.*]] = call i1 @is_less_than_100_1(i32 noundef [[CSRET]]) #[[ATTR7]]
2135; IS__CGSCC_OPM-NEXT:    ret i1 [[TRUE]]
2136;
2137; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
2138; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@propagate_range1
2139; IS__CGSCC_NPM-SAME: (i32 [[C:%.*]]) #[[ATTR3]] {
2140; IS__CGSCC_NPM-NEXT:    [[CSRET:%.*]] = call i32 @less_than_100_1(i32 [[C]]) #[[ATTR6]]
2141; IS__CGSCC_NPM-NEXT:    [[TRUE:%.*]] = call i1 @is_less_than_100_1(i32 noundef [[CSRET]]) #[[ATTR6]]
2142; IS__CGSCC_NPM-NEXT:    ret i1 [[TRUE]]
2143;
2144  %csret = call i32 @less_than_100_1(i32 %c)
2145  %true = call i1 @is_less_than_100_1(i32 %csret)
2146  ret i1 %true
2147}
2148
2149define internal i32 @less_than_100_2(i32 %c) {
2150;
2151; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2152; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@less_than_100_2
2153; IS__TUNIT_OPM-SAME: (i32 [[C:%.*]]) #[[ATTR2]] {
2154; IS__TUNIT_OPM-NEXT:    switch i32 [[C]], label [[OTHERWISE:%.*]] [
2155; IS__TUNIT_OPM-NEXT:    i32 0, label [[ONZERO:%.*]]
2156; IS__TUNIT_OPM-NEXT:    i32 1, label [[ONONE:%.*]]
2157; IS__TUNIT_OPM-NEXT:    i32 2, label [[ONTWO:%.*]]
2158; IS__TUNIT_OPM-NEXT:    i32 3, label [[ONTHREE:%.*]]
2159; IS__TUNIT_OPM-NEXT:    i32 4, label [[ONFOUR:%.*]]
2160; IS__TUNIT_OPM-NEXT:    i32 5, label [[ONFIVE:%.*]]
2161; IS__TUNIT_OPM-NEXT:    i32 6, label [[ONSIX:%.*]]
2162; IS__TUNIT_OPM-NEXT:    ]
2163; IS__TUNIT_OPM:       onzero:
2164; IS__TUNIT_OPM-NEXT:    ret i32 0
2165; IS__TUNIT_OPM:       onone:
2166; IS__TUNIT_OPM-NEXT:    ret i32 1
2167; IS__TUNIT_OPM:       ontwo:
2168; IS__TUNIT_OPM-NEXT:    ret i32 2
2169; IS__TUNIT_OPM:       onthree:
2170; IS__TUNIT_OPM-NEXT:    ret i32 3
2171; IS__TUNIT_OPM:       onfour:
2172; IS__TUNIT_OPM-NEXT:    ret i32 4
2173; IS__TUNIT_OPM:       onfive:
2174; IS__TUNIT_OPM-NEXT:    ret i32 5
2175; IS__TUNIT_OPM:       onsix:
2176; IS__TUNIT_OPM-NEXT:    ret i32 6
2177; IS__TUNIT_OPM:       otherwise:
2178; IS__TUNIT_OPM-NEXT:    ret i32 99
2179;
2180; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2181; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@less_than_100_2
2182; IS__TUNIT_NPM-SAME: (i32 [[C:%.*]]) #[[ATTR1]] {
2183; IS__TUNIT_NPM-NEXT:    switch i32 [[C]], label [[OTHERWISE:%.*]] [
2184; IS__TUNIT_NPM-NEXT:    i32 0, label [[ONZERO:%.*]]
2185; IS__TUNIT_NPM-NEXT:    i32 1, label [[ONONE:%.*]]
2186; IS__TUNIT_NPM-NEXT:    i32 2, label [[ONTWO:%.*]]
2187; IS__TUNIT_NPM-NEXT:    i32 3, label [[ONTHREE:%.*]]
2188; IS__TUNIT_NPM-NEXT:    i32 4, label [[ONFOUR:%.*]]
2189; IS__TUNIT_NPM-NEXT:    i32 5, label [[ONFIVE:%.*]]
2190; IS__TUNIT_NPM-NEXT:    i32 6, label [[ONSIX:%.*]]
2191; IS__TUNIT_NPM-NEXT:    ]
2192; IS__TUNIT_NPM:       onzero:
2193; IS__TUNIT_NPM-NEXT:    ret i32 0
2194; IS__TUNIT_NPM:       onone:
2195; IS__TUNIT_NPM-NEXT:    ret i32 1
2196; IS__TUNIT_NPM:       ontwo:
2197; IS__TUNIT_NPM-NEXT:    ret i32 2
2198; IS__TUNIT_NPM:       onthree:
2199; IS__TUNIT_NPM-NEXT:    ret i32 3
2200; IS__TUNIT_NPM:       onfour:
2201; IS__TUNIT_NPM-NEXT:    ret i32 4
2202; IS__TUNIT_NPM:       onfive:
2203; IS__TUNIT_NPM-NEXT:    ret i32 5
2204; IS__TUNIT_NPM:       onsix:
2205; IS__TUNIT_NPM-NEXT:    ret i32 6
2206; IS__TUNIT_NPM:       otherwise:
2207; IS__TUNIT_NPM-NEXT:    ret i32 99
2208;
2209; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2210; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@less_than_100_2
2211; IS__CGSCC_OPM-SAME: (i32 [[C:%.*]]) #[[ATTR3]] {
2212; IS__CGSCC_OPM-NEXT:    switch i32 [[C]], label [[OTHERWISE:%.*]] [
2213; IS__CGSCC_OPM-NEXT:    i32 0, label [[ONZERO:%.*]]
2214; IS__CGSCC_OPM-NEXT:    i32 1, label [[ONONE:%.*]]
2215; IS__CGSCC_OPM-NEXT:    i32 2, label [[ONTWO:%.*]]
2216; IS__CGSCC_OPM-NEXT:    i32 3, label [[ONTHREE:%.*]]
2217; IS__CGSCC_OPM-NEXT:    i32 4, label [[ONFOUR:%.*]]
2218; IS__CGSCC_OPM-NEXT:    i32 5, label [[ONFIVE:%.*]]
2219; IS__CGSCC_OPM-NEXT:    i32 6, label [[ONSIX:%.*]]
2220; IS__CGSCC_OPM-NEXT:    ]
2221; IS__CGSCC_OPM:       onzero:
2222; IS__CGSCC_OPM-NEXT:    ret i32 0
2223; IS__CGSCC_OPM:       onone:
2224; IS__CGSCC_OPM-NEXT:    ret i32 1
2225; IS__CGSCC_OPM:       ontwo:
2226; IS__CGSCC_OPM-NEXT:    ret i32 2
2227; IS__CGSCC_OPM:       onthree:
2228; IS__CGSCC_OPM-NEXT:    ret i32 3
2229; IS__CGSCC_OPM:       onfour:
2230; IS__CGSCC_OPM-NEXT:    ret i32 4
2231; IS__CGSCC_OPM:       onfive:
2232; IS__CGSCC_OPM-NEXT:    ret i32 5
2233; IS__CGSCC_OPM:       onsix:
2234; IS__CGSCC_OPM-NEXT:    ret i32 6
2235; IS__CGSCC_OPM:       otherwise:
2236; IS__CGSCC_OPM-NEXT:    ret i32 99
2237;
2238; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2239; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@less_than_100_2
2240; IS__CGSCC_NPM-SAME: (i32 [[C:%.*]]) #[[ATTR2]] {
2241; IS__CGSCC_NPM-NEXT:    switch i32 [[C]], label [[OTHERWISE:%.*]] [
2242; IS__CGSCC_NPM-NEXT:    i32 0, label [[ONZERO:%.*]]
2243; IS__CGSCC_NPM-NEXT:    i32 1, label [[ONONE:%.*]]
2244; IS__CGSCC_NPM-NEXT:    i32 2, label [[ONTWO:%.*]]
2245; IS__CGSCC_NPM-NEXT:    i32 3, label [[ONTHREE:%.*]]
2246; IS__CGSCC_NPM-NEXT:    i32 4, label [[ONFOUR:%.*]]
2247; IS__CGSCC_NPM-NEXT:    i32 5, label [[ONFIVE:%.*]]
2248; IS__CGSCC_NPM-NEXT:    i32 6, label [[ONSIX:%.*]]
2249; IS__CGSCC_NPM-NEXT:    ]
2250; IS__CGSCC_NPM:       onzero:
2251; IS__CGSCC_NPM-NEXT:    ret i32 0
2252; IS__CGSCC_NPM:       onone:
2253; IS__CGSCC_NPM-NEXT:    ret i32 1
2254; IS__CGSCC_NPM:       ontwo:
2255; IS__CGSCC_NPM-NEXT:    ret i32 2
2256; IS__CGSCC_NPM:       onthree:
2257; IS__CGSCC_NPM-NEXT:    ret i32 3
2258; IS__CGSCC_NPM:       onfour:
2259; IS__CGSCC_NPM-NEXT:    ret i32 4
2260; IS__CGSCC_NPM:       onfive:
2261; IS__CGSCC_NPM-NEXT:    ret i32 5
2262; IS__CGSCC_NPM:       onsix:
2263; IS__CGSCC_NPM-NEXT:    ret i32 6
2264; IS__CGSCC_NPM:       otherwise:
2265; IS__CGSCC_NPM-NEXT:    ret i32 99
2266;
2267  switch i32 %c, label %otherwise [ i32 0, label %onzero
2268  i32 1, label %onone
2269  i32 2, label %ontwo
2270  i32 3, label %onthree
2271  i32 4, label %onfour
2272  i32 5, label %onfive
2273  i32 6, label %onsix]
2274onzero:
2275  ret i32 0
2276onone:
2277  ret i32 1
2278ontwo:
2279  ret i32 2
2280onthree:
2281  ret i32 3
2282onfour:
2283  ret i32 4
2284onfive:
2285  ret i32 5
2286onsix:
2287  ret i32 6
2288otherwise:
2289  ret i32 99
2290}
2291
2292define internal i1 @is_less_than_100_2(i32 %c) {
2293;
2294; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2295; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@is_less_than_100_2
2296; IS__TUNIT_OPM-SAME: (i32 noundef [[C:%.*]]) #[[ATTR2]] {
2297; IS__TUNIT_OPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[C]], 100
2298; IS__TUNIT_OPM-NEXT:    ret i1 [[CMP]]
2299;
2300; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2301; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@is_less_than_100_2
2302; IS__TUNIT_NPM-SAME: (i32 noundef [[C:%.*]]) #[[ATTR1]] {
2303; IS__TUNIT_NPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[C]], 100
2304; IS__TUNIT_NPM-NEXT:    ret i1 [[CMP]]
2305;
2306; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2307; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@is_less_than_100_2
2308; IS__CGSCC_OPM-SAME: (i32 noundef [[C:%.*]]) #[[ATTR3]] {
2309; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[C]], 100
2310; IS__CGSCC_OPM-NEXT:    ret i1 [[CMP]]
2311;
2312; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2313; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@is_less_than_100_2
2314; IS__CGSCC_NPM-SAME: (i32 noundef [[C:%.*]]) #[[ATTR2]] {
2315; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[C]], 100
2316; IS__CGSCC_NPM-NEXT:    ret i1 [[CMP]]
2317;
2318  %cmp = icmp slt i32 %c, 100
2319  ret i1 %cmp
2320}
2321
2322define i1 @propagate_range2(i32 %c) {
2323; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2324; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@propagate_range2
2325; IS__TUNIT_OPM-SAME: (i32 [[C:%.*]]) #[[ATTR2]] {
2326; IS__TUNIT_OPM-NEXT:    [[CSRET1:%.*]] = call noundef i32 @less_than_100_2(i32 noundef 0) #[[ATTR5]]
2327; IS__TUNIT_OPM-NEXT:    [[TRUE1:%.*]] = call i1 @is_less_than_100_2(i32 noundef [[CSRET1]]) #[[ATTR5]]
2328; IS__TUNIT_OPM-NEXT:    [[CSRET2:%.*]] = call noundef i32 @less_than_100_2(i32 [[C]]) #[[ATTR5]]
2329; IS__TUNIT_OPM-NEXT:    [[TRUE2:%.*]] = call i1 @is_less_than_100_2(i32 noundef [[CSRET2]]) #[[ATTR5]]
2330; IS__TUNIT_OPM-NEXT:    [[TRUE:%.*]] = and i1 [[TRUE1]], [[TRUE2]]
2331; IS__TUNIT_OPM-NEXT:    ret i1 [[TRUE]]
2332;
2333; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2334; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@propagate_range2
2335; IS__TUNIT_NPM-SAME: (i32 [[C:%.*]]) #[[ATTR1]] {
2336; IS__TUNIT_NPM-NEXT:    [[CSRET1:%.*]] = call noundef i32 @less_than_100_2(i32 noundef 0) #[[ATTR4]]
2337; IS__TUNIT_NPM-NEXT:    [[TRUE1:%.*]] = call i1 @is_less_than_100_2(i32 noundef [[CSRET1]]) #[[ATTR4]]
2338; IS__TUNIT_NPM-NEXT:    [[CSRET2:%.*]] = call noundef i32 @less_than_100_2(i32 [[C]]) #[[ATTR4]]
2339; IS__TUNIT_NPM-NEXT:    [[TRUE2:%.*]] = call i1 @is_less_than_100_2(i32 noundef [[CSRET2]]) #[[ATTR4]]
2340; IS__TUNIT_NPM-NEXT:    [[TRUE:%.*]] = and i1 [[TRUE1]], [[TRUE2]]
2341; IS__TUNIT_NPM-NEXT:    ret i1 [[TRUE]]
2342;
2343; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
2344; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@propagate_range2
2345; IS__CGSCC_OPM-SAME: (i32 [[C:%.*]]) #[[ATTR4]] {
2346; IS__CGSCC_OPM-NEXT:    [[CSRET1:%.*]] = call i32 @less_than_100_2(i32 noundef 0) #[[ATTR7]]
2347; IS__CGSCC_OPM-NEXT:    [[TRUE1:%.*]] = call i1 @is_less_than_100_2(i32 noundef [[CSRET1]]) #[[ATTR7]]
2348; IS__CGSCC_OPM-NEXT:    [[CSRET2:%.*]] = call i32 @less_than_100_2(i32 [[C]]) #[[ATTR7]]
2349; IS__CGSCC_OPM-NEXT:    [[TRUE2:%.*]] = call i1 @is_less_than_100_2(i32 noundef [[CSRET2]]) #[[ATTR7]]
2350; IS__CGSCC_OPM-NEXT:    [[TRUE:%.*]] = and i1 [[TRUE1]], [[TRUE2]]
2351; IS__CGSCC_OPM-NEXT:    ret i1 [[TRUE]]
2352;
2353; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
2354; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@propagate_range2
2355; IS__CGSCC_NPM-SAME: (i32 [[C:%.*]]) #[[ATTR3]] {
2356; IS__CGSCC_NPM-NEXT:    [[CSRET1:%.*]] = call i32 @less_than_100_2(i32 noundef 0) #[[ATTR6]]
2357; IS__CGSCC_NPM-NEXT:    [[TRUE1:%.*]] = call i1 @is_less_than_100_2(i32 noundef [[CSRET1]]) #[[ATTR6]]
2358; IS__CGSCC_NPM-NEXT:    [[CSRET2:%.*]] = call i32 @less_than_100_2(i32 [[C]]) #[[ATTR6]]
2359; IS__CGSCC_NPM-NEXT:    [[TRUE2:%.*]] = call i1 @is_less_than_100_2(i32 noundef [[CSRET2]]) #[[ATTR6]]
2360; IS__CGSCC_NPM-NEXT:    [[TRUE:%.*]] = and i1 [[TRUE1]], [[TRUE2]]
2361; IS__CGSCC_NPM-NEXT:    ret i1 [[TRUE]]
2362;
2363  %csret1 = call i32 @less_than_100_2(i32 0)
2364  %true1 = call i1 @is_less_than_100_2(i32 %csret1)
2365  %csret2 = call i32 @less_than_100_2(i32 %c)
2366  %true2 = call i1 @is_less_than_100_2(i32 %csret2)
2367  %true = and i1 %true1, %true2
2368  ret i1 %true
2369}
2370
2371define internal i1 @non_zero(i8 %v) {
2372; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2373; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@non_zero
2374; IS__TUNIT_OPM-SAME: (i8 [[V:%.*]]) #[[ATTR2]] {
2375; IS__TUNIT_OPM-NEXT:    [[R:%.*]] = icmp ne i8 [[V]], 0
2376; IS__TUNIT_OPM-NEXT:    ret i1 [[R]]
2377;
2378; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2379; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@non_zero
2380; IS__TUNIT_NPM-SAME: (i8 [[V:%.*]]) #[[ATTR1]] {
2381; IS__TUNIT_NPM-NEXT:    [[R:%.*]] = icmp ne i8 [[V]], 0
2382; IS__TUNIT_NPM-NEXT:    ret i1 [[R]]
2383;
2384; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2385; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@non_zero
2386; IS__CGSCC_OPM-SAME: (i8 [[V:%.*]]) #[[ATTR3]] {
2387; IS__CGSCC_OPM-NEXT:    [[R:%.*]] = icmp ne i8 [[V]], 0
2388; IS__CGSCC_OPM-NEXT:    ret i1 [[R]]
2389;
2390; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
2391; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@non_zero
2392; IS__CGSCC_NPM-SAME: (i8 [[V:%.*]]) #[[ATTR2]] {
2393; IS__CGSCC_NPM-NEXT:    [[R:%.*]] = icmp ne i8 [[V]], 0
2394; IS__CGSCC_NPM-NEXT:    ret i1 [[R]]
2395;
2396  %r = icmp ne i8 %v, 0
2397  ret i1 %r
2398}
2399
2400; Avoid range metadata for %l below
2401define i1 @context(i8* %p) {
2402; IS__TUNIT_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
2403; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@context
2404; IS__TUNIT_OPM-SAME: (i8* nocapture nofree noundef nonnull readonly dereferenceable(1) [[P:%.*]]) #[[ATTR0]] {
2405; IS__TUNIT_OPM-NEXT:    [[L:%.*]] = load i8, i8* [[P]], align 1
2406; IS__TUNIT_OPM-NEXT:    [[C:%.*]] = icmp slt i8 0, [[L]]
2407; IS__TUNIT_OPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
2408; IS__TUNIT_OPM:       t:
2409; IS__TUNIT_OPM-NEXT:    [[R:%.*]] = call i1 @non_zero(i8 [[L]]) #[[ATTR5]]
2410; IS__TUNIT_OPM-NEXT:    ret i1 [[R]]
2411; IS__TUNIT_OPM:       f:
2412; IS__TUNIT_OPM-NEXT:    ret i1 false
2413;
2414; IS__TUNIT_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
2415; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@context
2416; IS__TUNIT_NPM-SAME: (i8* nocapture nofree noundef nonnull readonly dereferenceable(1) [[P:%.*]]) #[[ATTR0]] {
2417; IS__TUNIT_NPM-NEXT:    [[L:%.*]] = load i8, i8* [[P]], align 1
2418; IS__TUNIT_NPM-NEXT:    [[C:%.*]] = icmp slt i8 0, [[L]]
2419; IS__TUNIT_NPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
2420; IS__TUNIT_NPM:       t:
2421; IS__TUNIT_NPM-NEXT:    [[R:%.*]] = call i1 @non_zero(i8 [[L]]) #[[ATTR4]]
2422; IS__TUNIT_NPM-NEXT:    ret i1 [[R]]
2423; IS__TUNIT_NPM:       f:
2424; IS__TUNIT_NPM-NEXT:    ret i1 false
2425;
2426; IS__CGSCC_OPM: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
2427; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@context
2428; IS__CGSCC_OPM-SAME: (i8* nocapture nofree noundef nonnull readonly dereferenceable(1) [[P:%.*]]) #[[ATTR1]] {
2429; IS__CGSCC_OPM-NEXT:    [[L:%.*]] = load i8, i8* [[P]], align 1
2430; IS__CGSCC_OPM-NEXT:    [[C:%.*]] = icmp slt i8 0, [[L]]
2431; IS__CGSCC_OPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
2432; IS__CGSCC_OPM:       t:
2433; IS__CGSCC_OPM-NEXT:    [[R:%.*]] = call i1 @non_zero(i8 [[L]]) #[[ATTR7]]
2434; IS__CGSCC_OPM-NEXT:    ret i1 [[R]]
2435; IS__CGSCC_OPM:       f:
2436; IS__CGSCC_OPM-NEXT:    ret i1 false
2437;
2438; IS__CGSCC_NPM: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
2439; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@context
2440; IS__CGSCC_NPM-SAME: (i8* nocapture nofree noundef nonnull readonly dereferenceable(1) [[P:%.*]]) #[[ATTR1]] {
2441; IS__CGSCC_NPM-NEXT:    [[L:%.*]] = load i8, i8* [[P]], align 1
2442; IS__CGSCC_NPM-NEXT:    [[C:%.*]] = icmp slt i8 0, [[L]]
2443; IS__CGSCC_NPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
2444; IS__CGSCC_NPM:       t:
2445; IS__CGSCC_NPM-NEXT:    [[R:%.*]] = call i1 @non_zero(i8 [[L]]) #[[ATTR6]]
2446; IS__CGSCC_NPM-NEXT:    ret i1 [[R]]
2447; IS__CGSCC_NPM:       f:
2448; IS__CGSCC_NPM-NEXT:    ret i1 false
2449;
2450  %l = load i8, i8* %p
2451  %c = icmp slt i8 0, %l
2452  br i1 %c, label %t, label %f
2453t:
2454  %r = call i1 @non_zero(i8 %l)
2455  ret i1 %r
2456f:
2457  ret i1 false
2458}
2459
2460
2461define void @spam(i32* %arg, i32* %arg1) {
2462; CHECK-LABEL: define {{[^@]+}}@spam
2463; CHECK-SAME: (i32* nocapture nofree noundef nonnull readonly align 8 dereferenceable(4) [[ARG:%.*]], i32* nocapture nofree readnone [[ARG1:%.*]]) {
2464; CHECK-NEXT:  bb:
2465; CHECK-NEXT:    [[TMP:%.*]] = load i32, i32* [[ARG]], align 8
2466; CHECK-NEXT:    [[TMP2:%.*]] = icmp ult i32 [[TMP]], 4
2467; CHECK-NEXT:    br i1 [[TMP2]], label [[BB3:%.*]], label [[BB4:%.*]]
2468; CHECK:       bb3:
2469; CHECK-NEXT:    call fastcc void @wobble(i32 signext [[TMP]])
2470; CHECK-NEXT:    br label [[BB5:%.*]]
2471; CHECK:       bb4:
2472; CHECK-NEXT:    call void @ham(i32 [[TMP]])
2473; CHECK-NEXT:    br label [[BB5]]
2474; CHECK:       bb5:
2475; CHECK-NEXT:    ret void
2476;
2477bb:
2478  %tmp = load i32, i32* %arg, align 8
2479  %tmp2 = icmp ult i32 %tmp, 4
2480  br i1 %tmp2, label %bb3, label %bb4
2481
2482bb3:                                              ; preds = %bb
2483  call fastcc void @wobble(i32 signext %tmp)
2484  br label %bb5
2485
2486bb4:                                              ; preds = %bb
2487  call void @ham(i32 %tmp)
2488  br label %bb5
2489
2490bb5:                                              ; preds = %bb4, %bb3
2491  ret void
2492}
2493
2494define internal fastcc void @wobble(i32 signext %arg) {
2495; CHECK-LABEL: define {{[^@]+}}@wobble
2496; CHECK-SAME: (i32 signext [[ARG:%.*]]) {
2497; CHECK-NEXT:  bb:
2498; CHECK-NEXT:    [[TMP:%.*]] = icmp ult i32 [[ARG]], 2
2499; CHECK-NEXT:    br i1 [[TMP]], label [[BB1:%.*]], label [[BB2:%.*]]
2500; CHECK:       bb1:
2501; CHECK-NEXT:    call void @barney(i32 noundef signext 32, i32 noundef signext 0)
2502; CHECK-NEXT:    br label [[BB3:%.*]]
2503; CHECK:       bb2:
2504; CHECK-NEXT:    br label [[BB3]]
2505; CHECK:       bb3:
2506; CHECK-NEXT:    ret void
2507;
2508bb:
2509  %tmp = icmp ult i32 %arg, 2
2510  br i1 %tmp, label %bb1, label %bb2
2511
2512bb1:                                              ; preds = %bb
2513  call void @barney(i32 signext 32, i32 signext 0)
2514  br label %bb3
2515
2516bb2:                                              ; preds = %bb
2517  br label %bb3
2518
2519bb3:                                              ; preds = %bb2, %bb1
2520  ret void
2521}
2522
2523define i1 @loop_1(i32 %N) {
2524; IS__TUNIT_OPM: Function Attrs: nofree norecurse nosync nounwind readnone
2525; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@loop_1
2526; IS__TUNIT_OPM-SAME: (i32 [[N:%.*]]) #[[ATTR1]] {
2527; IS__TUNIT_OPM-NEXT:  entry:
2528; IS__TUNIT_OPM-NEXT:    br label [[HEADER:%.*]]
2529; IS__TUNIT_OPM:       header:
2530; IS__TUNIT_OPM-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[AND:%.*]], [[HEADER]] ]
2531; IS__TUNIT_OPM-NEXT:    [[INC:%.*]] = add i32 [[I]], 1
2532; IS__TUNIT_OPM-NEXT:    [[AND]] = and i32 [[INC]], 9999
2533; IS__TUNIT_OPM-NEXT:    [[CMP:%.*]] = icmp ne i32 [[N]], [[AND]]
2534; IS__TUNIT_OPM-NEXT:    br i1 [[CMP]], label [[HEADER]], label [[EXIT:%.*]]
2535; IS__TUNIT_OPM:       exit:
2536; IS__TUNIT_OPM-NEXT:    [[R:%.*]] = icmp sle i32 [[I]], 5
2537; IS__TUNIT_OPM-NEXT:    ret i1 [[R]]
2538;
2539; IS__TUNIT_NPM: Function Attrs: nofree norecurse nosync nounwind readnone
2540; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@loop_1
2541; IS__TUNIT_NPM-SAME: (i32 [[N:%.*]]) #[[ATTR2:[0-9]+]] {
2542; IS__TUNIT_NPM-NEXT:  entry:
2543; IS__TUNIT_NPM-NEXT:    br label [[HEADER:%.*]]
2544; IS__TUNIT_NPM:       header:
2545; IS__TUNIT_NPM-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[AND:%.*]], [[HEADER]] ]
2546; IS__TUNIT_NPM-NEXT:    [[INC:%.*]] = add i32 [[I]], 1
2547; IS__TUNIT_NPM-NEXT:    [[AND]] = and i32 [[INC]], 9999
2548; IS__TUNIT_NPM-NEXT:    [[CMP:%.*]] = icmp ne i32 [[N]], [[AND]]
2549; IS__TUNIT_NPM-NEXT:    br i1 [[CMP]], label [[HEADER]], label [[EXIT:%.*]]
2550; IS__TUNIT_NPM:       exit:
2551; IS__TUNIT_NPM-NEXT:    [[R:%.*]] = icmp sle i32 [[I]], 5
2552; IS__TUNIT_NPM-NEXT:    ret i1 [[R]]
2553;
2554; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone
2555; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@loop_1
2556; IS__CGSCC_OPM-SAME: (i32 [[N:%.*]]) #[[ATTR2]] {
2557; IS__CGSCC_OPM-NEXT:  entry:
2558; IS__CGSCC_OPM-NEXT:    br label [[HEADER:%.*]]
2559; IS__CGSCC_OPM:       header:
2560; IS__CGSCC_OPM-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[AND:%.*]], [[HEADER]] ]
2561; IS__CGSCC_OPM-NEXT:    [[INC:%.*]] = add i32 [[I]], 1
2562; IS__CGSCC_OPM-NEXT:    [[AND]] = and i32 [[INC]], 9999
2563; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp ne i32 [[N]], [[AND]]
2564; IS__CGSCC_OPM-NEXT:    br i1 [[CMP]], label [[HEADER]], label [[EXIT:%.*]]
2565; IS__CGSCC_OPM:       exit:
2566; IS__CGSCC_OPM-NEXT:    [[R:%.*]] = icmp sle i32 [[I]], 5
2567; IS__CGSCC_OPM-NEXT:    ret i1 [[R]]
2568;
2569; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone
2570; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@loop_1
2571; IS__CGSCC_NPM-SAME: (i32 [[N:%.*]]) #[[ATTR4:[0-9]+]] {
2572; IS__CGSCC_NPM-NEXT:  entry:
2573; IS__CGSCC_NPM-NEXT:    br label [[HEADER:%.*]]
2574; IS__CGSCC_NPM:       header:
2575; IS__CGSCC_NPM-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[AND:%.*]], [[HEADER]] ]
2576; IS__CGSCC_NPM-NEXT:    [[INC:%.*]] = add i32 [[I]], 1
2577; IS__CGSCC_NPM-NEXT:    [[AND]] = and i32 [[INC]], 9999
2578; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp ne i32 [[N]], [[AND]]
2579; IS__CGSCC_NPM-NEXT:    br i1 [[CMP]], label [[HEADER]], label [[EXIT:%.*]]
2580; IS__CGSCC_NPM:       exit:
2581; IS__CGSCC_NPM-NEXT:    [[R:%.*]] = icmp sle i32 [[I]], 5
2582; IS__CGSCC_NPM-NEXT:    ret i1 [[R]]
2583;
2584entry:
2585  br label %header
2586header:
2587  %i = phi i32 [0, %entry], [%and, %header]
2588  %inc = add i32 %i, 1
2589  %and = and i32 %inc, 9999
2590  %cmp = icmp ne i32 %N, %and
2591  br i1 %cmp, label %header, label %exit
2592exit:
2593  %r = icmp sle i32 %i, 5
2594  ret i1 %r
2595}
2596
2597declare void @ham(i32)
2598
2599declare void @barney(i32 signext, i32 signext)
2600
2601
2602!0 = !{i32 0, i32 10}
2603!1 = !{i32 10, i32 100}
2604;.
2605; IS__TUNIT_OPM: attributes #[[ATTR0]] = { argmemonly nofree norecurse nosync nounwind readonly willreturn }
2606; IS__TUNIT_OPM: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind readnone }
2607; IS__TUNIT_OPM: attributes #[[ATTR2]] = { nofree norecurse nosync nounwind readnone willreturn }
2608; IS__TUNIT_OPM: attributes #[[ATTR3]] = { nofree nosync nounwind readonly willreturn }
2609; IS__TUNIT_OPM: attributes #[[ATTR4]] = { nofree nosync nounwind readnone }
2610; IS__TUNIT_OPM: attributes #[[ATTR5]] = { nofree nosync nounwind readnone willreturn }
2611;.
2612; IS__TUNIT_NPM: attributes #[[ATTR0]] = { argmemonly nofree norecurse nosync nounwind readonly willreturn }
2613; IS__TUNIT_NPM: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind readnone willreturn }
2614; IS__TUNIT_NPM: attributes #[[ATTR2]] = { nofree norecurse nosync nounwind readnone }
2615; IS__TUNIT_NPM: attributes #[[ATTR3]] = { nofree nosync nounwind readonly willreturn }
2616; IS__TUNIT_NPM: attributes #[[ATTR4]] = { nofree nosync nounwind readnone willreturn }
2617;.
2618; IS__CGSCC_OPM: attributes #[[ATTR0]] = { argmemonly nofree norecurse nosync nounwind readonly willreturn }
2619; IS__CGSCC_OPM: attributes #[[ATTR1]] = { argmemonly nofree nosync nounwind readonly willreturn }
2620; IS__CGSCC_OPM: attributes #[[ATTR2]] = { nofree norecurse nosync nounwind readnone }
2621; IS__CGSCC_OPM: attributes #[[ATTR3]] = { nofree norecurse nosync nounwind readnone willreturn }
2622; IS__CGSCC_OPM: attributes #[[ATTR4]] = { nofree nosync nounwind readnone willreturn }
2623; IS__CGSCC_OPM: attributes #[[ATTR5]] = { readonly willreturn }
2624; IS__CGSCC_OPM: attributes #[[ATTR6]] = { nounwind readnone }
2625; IS__CGSCC_OPM: attributes #[[ATTR7]] = { readnone willreturn }
2626;.
2627; IS__CGSCC_NPM: attributes #[[ATTR0]] = { argmemonly nofree norecurse nosync nounwind readonly willreturn }
2628; IS__CGSCC_NPM: attributes #[[ATTR1]] = { argmemonly nofree nosync nounwind readonly willreturn }
2629; IS__CGSCC_NPM: attributes #[[ATTR2]] = { nofree norecurse nosync nounwind readnone willreturn }
2630; IS__CGSCC_NPM: attributes #[[ATTR3]] = { nofree nosync nounwind readnone willreturn }
2631; IS__CGSCC_NPM: attributes #[[ATTR4]] = { nofree norecurse nosync nounwind readnone }
2632; IS__CGSCC_NPM: attributes #[[ATTR5]] = { readonly willreturn }
2633; IS__CGSCC_NPM: attributes #[[ATTR6]] = { readnone willreturn }
2634;.
2635; IS__TUNIT_OPM: [[RNG0]] = !{i32 0, i32 10}
2636; IS__TUNIT_OPM: [[RNG1]] = !{i32 10, i32 100}
2637; IS__TUNIT_OPM: [[RNG2]] = !{i32 200, i32 1091}
2638;.
2639; IS__TUNIT_NPM: [[RNG0]] = !{i32 0, i32 10}
2640; IS__TUNIT_NPM: [[RNG1]] = !{i32 10, i32 100}
2641; IS__TUNIT_NPM: [[RNG2]] = !{i32 200, i32 1091}
2642; IS__TUNIT_NPM: [[RNG3]] = !{i32 1, i32 -2147483648}
2643;.
2644; IS__CGSCC____: [[RNG0]] = !{i32 0, i32 10}
2645; IS__CGSCC____: [[RNG1]] = !{i32 10, i32 100}
2646;.
2647