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