1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --check-globals
2; call site specific analysis is enabled
3
4; RUN: opt -attributor -enable-new-pm=0 -attributor-enable-call-site-specific-deduction=true -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
5
6; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-enable-call-site-specific-deduction=true -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
7
8; RUN: opt -attributor-cgscc -attributor-enable-call-site-specific-deduction=true -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
9
10; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-enable-call-site-specific-deduction=true -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
11
12define dso_local i32 @test_range1(i32 %0) #0 {
13; CHECK-LABEL: define {{[^@]+}}@test_range1
14; CHECK-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] {
15; CHECK-NEXT:    [[TMP2:%.*]] = icmp ne i32 [[TMP0]], 0
16; CHECK-NEXT:    br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
17; CHECK:       3:
18; CHECK-NEXT:    br label [[TMP5:%.*]]
19; CHECK:       4:
20; CHECK-NEXT:    br label [[TMP5]]
21; CHECK:       5:
22; CHECK-NEXT:    [[DOT0:%.*]] = phi i32 [ 100, [[TMP3]] ], [ 0, [[TMP4]] ]
23; CHECK-NEXT:    ret i32 [[DOT0]]
24;
25  %2 = icmp ne i32 %0, 0
26  br i1 %2, label %3, label %4
27
283:                                                ; preds = %1
29  br label %5
30
314:                                                ; preds = %1
32  br label %5
33
345:                                                ; preds = %4, %3
35  %.0 = phi i32 [ 100, %3 ], [ 0, %4 ]
36  ret i32 %.0
37}
38
39define i32 @test_range2(i32 %0) #0 {
40; CHECK-LABEL: define {{[^@]+}}@test_range2
41; CHECK-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0]] {
42; CHECK-NEXT:    [[TMP2:%.*]] = icmp ne i32 [[TMP0]], 0
43; CHECK-NEXT:    br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
44; CHECK:       3:
45; CHECK-NEXT:    br label [[TMP5:%.*]]
46; CHECK:       4:
47; CHECK-NEXT:    br label [[TMP5]]
48; CHECK:       5:
49; CHECK-NEXT:    [[DOT0:%.*]] = phi i32 [ 100, [[TMP3]] ], [ 200, [[TMP4]] ]
50; CHECK-NEXT:    ret i32 [[DOT0]]
51;
52  %2 = icmp ne i32 %0, 0
53  br i1 %2, label %3, label %4
54
553:                                                ; preds = %1
56  br label %5
57
584:                                                ; preds = %1
59  br label %5
60
615:                                                ; preds = %4, %3
62  %.0 = phi i32 [ 100, %3 ], [ 200, %4 ]
63  ret i32 %.0
64}
65define i32 @test(i32 %0, i32 %1) #0 {
66; IS__TUNIT____-LABEL: define {{[^@]+}}@test
67; IS__TUNIT____-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR0]] {
68; IS__TUNIT____-NEXT:    [[TMP3:%.*]] = icmp ne i32 [[TMP1]], 0
69; IS__TUNIT____-NEXT:    br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP6:%.*]]
70; IS__TUNIT____:       4:
71; IS__TUNIT____-NEXT:    [[TMP5:%.*]] = call i32 @test_range1(i32 [[TMP0]])
72; IS__TUNIT____-NEXT:    br label [[TMP8:%.*]]
73; IS__TUNIT____:       6:
74; IS__TUNIT____-NEXT:    [[TMP7:%.*]] = call i32 @test_range2(i32 [[TMP0]])
75; IS__TUNIT____-NEXT:    br label [[TMP8]]
76; IS__TUNIT____:       8:
77; IS__TUNIT____-NEXT:    [[DOT0:%.*]] = phi i32 [ [[TMP5]], [[TMP4]] ], [ [[TMP7]], [[TMP6]] ]
78; IS__TUNIT____-NEXT:    ret i32 [[DOT0]]
79;
80; IS__CGSCC____-LABEL: define {{[^@]+}}@test
81; IS__CGSCC____-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR1:[0-9]+]] {
82; IS__CGSCC____-NEXT:    [[TMP3:%.*]] = icmp ne i32 [[TMP1]], 0
83; IS__CGSCC____-NEXT:    br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP6:%.*]]
84; IS__CGSCC____:       4:
85; IS__CGSCC____-NEXT:    [[TMP5:%.*]] = call noundef i32 @test_range1(i32 [[TMP0]])
86; IS__CGSCC____-NEXT:    br label [[TMP8:%.*]]
87; IS__CGSCC____:       6:
88; IS__CGSCC____-NEXT:    [[TMP7:%.*]] = call noundef i32 @test_range2(i32 [[TMP0]])
89; IS__CGSCC____-NEXT:    br label [[TMP8]]
90; IS__CGSCC____:       8:
91; IS__CGSCC____-NEXT:    [[DOT0:%.*]] = phi i32 [ [[TMP5]], [[TMP4]] ], [ [[TMP7]], [[TMP6]] ]
92; IS__CGSCC____-NEXT:    ret i32 [[DOT0]]
93;
94  %3 = icmp ne i32 %1, 0
95  br i1 %3, label %4, label %6
96
974:                                                ; preds = %2
98  %5 = call i32 @test_range1(i32 %0)
99  br label %8
100
1016:                                                ; preds = %2
102  %7 = call i32 @test_range2(i32 %0)
103  br label %8
104
1058:                                                ; preds = %6, %4
106  %.0 = phi i32 [ %5, %4 ], [ %7, %6 ]
107  ret i32 %.0
108}
109
110define i32 @test_pcheck1(i32 %0) #0 {
111; IS__TUNIT____-LABEL: define {{[^@]+}}@test_pcheck1
112; IS__TUNIT____-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0]] {
113; IS__TUNIT____-NEXT:    [[TMP2:%.*]] = call i32 @test(i32 [[TMP0]], i32 noundef 1)
114; IS__TUNIT____-NEXT:    [[TMP3:%.*]] = icmp slt i32 [[TMP2]], 101
115; IS__TUNIT____-NEXT:    [[TMP4:%.*]] = zext i1 [[TMP3]] to i32
116; IS__TUNIT____-NEXT:    ret i32 [[TMP4]]
117;
118; IS__CGSCC____-LABEL: define {{[^@]+}}@test_pcheck1
119; IS__CGSCC____-SAME: (i32 [[TMP0:%.*]]) #[[ATTR1]] {
120; IS__CGSCC____-NEXT:    [[TMP2:%.*]] = call i32 @test(i32 [[TMP0]], i32 noundef 1)
121; IS__CGSCC____-NEXT:    [[TMP3:%.*]] = icmp slt i32 [[TMP2]], 101
122; IS__CGSCC____-NEXT:    [[TMP4:%.*]] = zext i1 [[TMP3]] to i32
123; IS__CGSCC____-NEXT:    ret i32 [[TMP4]]
124;
125; IS__TUNIT_____ENABLED-LABEL: define {{[^@]+}}@test_pcheck1
126; IS__TUNIT_____ENABLED-SAME: (i32 [[TMP0:%.*]])
127; IS__TUNIT_____ENABLED-NEXT:    ret i32 1
128  %2 = call i32 @test(i32 %0, i32 1)
129  %3 = icmp slt i32 %2, 101
130  %4 = zext i1 %3 to i32
131  ret i32 %4
132}
133
134define i32 @test_pcheck2(i32 %0) #0 {
135; IS__TUNIT____-LABEL: define {{[^@]+}}@test_pcheck2
136; IS__TUNIT____-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0]] {
137; IS__TUNIT____-NEXT:    [[TMP2:%.*]] = call i32 @test(i32 [[TMP0]], i32 noundef 0)
138; IS__TUNIT____-NEXT:    [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], 99
139; IS__TUNIT____-NEXT:    [[TMP4:%.*]] = zext i1 [[TMP3]] to i32
140; IS__TUNIT____-NEXT:    ret i32 [[TMP4]]
141;
142; IS__CGSCC____-LABEL: define {{[^@]+}}@test_pcheck2
143; IS__CGSCC____-SAME: (i32 [[TMP0:%.*]]) #[[ATTR1]] {
144; IS__CGSCC____-NEXT:    [[TMP2:%.*]] = call i32 @test(i32 [[TMP0]], i32 noundef 0)
145; IS__CGSCC____-NEXT:    [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], 99
146; IS__CGSCC____-NEXT:    [[TMP4:%.*]] = zext i1 [[TMP3]] to i32
147; IS__CGSCC____-NEXT:    ret i32 [[TMP4]]
148;
149  %2 = call i32 @test(i32 %0, i32 0)
150  %3 = icmp sgt i32 %2, 99
151  %4 = zext i1 %3 to i32
152  ret i32 %4
153}
154
155define i32 @test_ncheck1(i32 %0) #0 {
156; IS__TUNIT____-LABEL: define {{[^@]+}}@test_ncheck1
157; IS__TUNIT____-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0]] {
158; IS__TUNIT____-NEXT:    [[TMP2:%.*]] = call i32 @test(i32 [[TMP0]], i32 noundef 1)
159; IS__TUNIT____-NEXT:    [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], 50
160; IS__TUNIT____-NEXT:    [[TMP4:%.*]] = zext i1 [[TMP3]] to i32
161; IS__TUNIT____-NEXT:    ret i32 [[TMP4]]
162;
163; IS__CGSCC____-LABEL: define {{[^@]+}}@test_ncheck1
164; IS__CGSCC____-SAME: (i32 [[TMP0:%.*]]) #[[ATTR1]] {
165; IS__CGSCC____-NEXT:    [[TMP2:%.*]] = call i32 @test(i32 [[TMP0]], i32 noundef 1)
166; IS__CGSCC____-NEXT:    [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], 50
167; IS__CGSCC____-NEXT:    [[TMP4:%.*]] = zext i1 [[TMP3]] to i32
168; IS__CGSCC____-NEXT:    ret i32 [[TMP4]]
169;
170  %2 = call i32 @test(i32 %0, i32 1)
171  %3 = icmp sgt i32 %2, 50
172  %4 = zext i1 %3 to i32
173  ret i32 %4
174}
175
176define i32 @test_ncheck2(i32 %0) #0 {
177; IS__TUNIT____-LABEL: define {{[^@]+}}@test_ncheck2
178; IS__TUNIT____-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0]] {
179; IS__TUNIT____-NEXT:    [[TMP2:%.*]] = call i32 @test(i32 [[TMP0]], i32 noundef 0)
180; IS__TUNIT____-NEXT:    [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], 150
181; IS__TUNIT____-NEXT:    [[TMP4:%.*]] = zext i1 [[TMP3]] to i32
182; IS__TUNIT____-NEXT:    ret i32 [[TMP4]]
183;
184; IS__CGSCC____-LABEL: define {{[^@]+}}@test_ncheck2
185; IS__CGSCC____-SAME: (i32 [[TMP0:%.*]]) #[[ATTR1]] {
186; IS__CGSCC____-NEXT:    [[TMP2:%.*]] = call i32 @test(i32 [[TMP0]], i32 noundef 0)
187; IS__CGSCC____-NEXT:    [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], 150
188; IS__CGSCC____-NEXT:    [[TMP4:%.*]] = zext i1 [[TMP3]] to i32
189; IS__CGSCC____-NEXT:    ret i32 [[TMP4]]
190;
191  %2 = call i32 @test(i32 %0, i32 0)
192  %3 = icmp sgt i32 %2, 150
193  %4 = zext i1 %3 to i32
194  ret i32 %4
195}
196
197attributes #0 = { noinline nounwind sspstrong uwtable}
198
199; IS__TUNIT_____: !0 = !{i32 0, i32 101}
200; IS__TUNIT_____: !1 = !{i32 100, i32 201}
201;.
202; IS__TUNIT____: attributes #[[ATTR0]] = { nofree noinline norecurse nosync nounwind readnone sspstrong willreturn uwtable }
203; IS__TUNIT____: attributes #[[ATTR1:[0-9]+]] = { nofree nosync nounwind readnone willreturn }
204;.
205; IS__CGSCC____: attributes #[[ATTR0]] = { nofree noinline norecurse nosync nounwind readnone sspstrong willreturn uwtable }
206; IS__CGSCC____: attributes #[[ATTR1]] = { nofree noinline nosync nounwind readnone sspstrong willreturn uwtable }
207; IS__CGSCC____: attributes #[[ATTR2:[0-9]+]] = { readnone willreturn }
208;.
209