1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt < %s -passes='print<scalar-evolution>,simple-loop-unswitch<nontrivial>' -verify-scev -S | FileCheck %s
4 ; This is a reproducer for https://github.com/llvm/llvm-project/issues/61080
6 ; Note that the print<scalar-evolution> in the beginning of the pipeline is
7 ; needed for reproducing the original problem, as we need something that
8 ; calculate SCEV before the loop unswitch, to verify that we invalidate SCEV
9 ; correctly while doing the unswitch.
11 ; Verify that we no longer hit that assert. Also perform checks to show the IR
12 ; transformation that is going on in this test.
15 define i32 @foo(i1 %not) {
16 ; CHECK-LABEL: define i32 @foo
17 ; CHECK-SAME: (i1 [[NOT:%.*]]) {
19 ; CHECK-NEXT: [[FALSE:%.*]] = and i1 true, false
20 ; CHECK-NEXT: br i1 [[NOT]], label [[ENTRY_SPLIT_US:%.*]], label [[ENTRY_SPLIT:%.*]]
21 ; CHECK: entry.split.us:
22 ; CHECK-NEXT: br i1 [[FALSE]], label [[ENTRY_SPLIT_US_SPLIT_US:%.*]], label [[ENTRY_SPLIT_US_SPLIT:%.*]]
23 ; CHECK: entry.split.us.split.us:
24 ; CHECK-NEXT: br label [[FOR_COND_US_US:%.*]]
25 ; CHECK: for.cond.us.us:
26 ; CHECK-NEXT: br label [[FOR_COND_SPLIT_US_US_US:%.*]]
27 ; CHECK: for.cond.split.us.us.us:
28 ; CHECK-NEXT: br label [[FOR_COND_SPLIT_US_SPLIT_US_SPLIT_US_SPLIT_US:%.*]]
29 ; CHECK: for.cond.split.us.split.us.split.us.split.us:
30 ; CHECK-NEXT: br label [[FOR_COND_SPLIT_US_SPLIT_US_SPLIT_US:%.*]]
31 ; CHECK: entry.split.us.split:
32 ; CHECK-NEXT: br label [[FOR_COND_US:%.*]]
34 ; CHECK-NEXT: br label [[FOR_COND_SPLIT_US_US:%.*]]
35 ; CHECK: for.inc11.us:
36 ; CHECK-NEXT: br label [[FOR_COND_US]]
37 ; CHECK: for.cond.split.us.us:
38 ; CHECK-NEXT: br label [[FOR_COND_SPLIT_US_SPLIT_US11:%.*]]
39 ; CHECK: for.cond5.preheader.us.us9:
40 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT_US_US_US10:%.*]]
41 ; CHECK: for.inc8.us.us:
42 ; CHECK-NEXT: br i1 false, label [[FOR_INC8_FOR_COND5_PREHEADER_CRIT_EDGE_US_US:%.*]], label [[FOR_INC11_SPLIT_US_US:%.*]]
43 ; CHECK: for.inc8.for.cond5.preheader_crit_edge.us.us:
44 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_US_US9:%.*]]
45 ; CHECK: for.end.us.us:
46 ; CHECK-NEXT: br i1 false, label [[FOR_INC8_US_US:%.*]], label [[CLEANUP15_SPLIT_US_SPLIT_US:%.*]]
47 ; CHECK: for.cond5.preheader.split.us.us.us10:
48 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT_US_SPLIT_US7_US:%.*]]
49 ; CHECK: for.body7.us.us4.us:
50 ; CHECK-NEXT: br label [[HANDLER_POINTER_OVERFLOW_US_US5_US:%.*]]
51 ; CHECK: handler.pointer_overflow.us.us5.us:
52 ; CHECK-NEXT: br label [[CONT_US_US6_US:%.*]]
53 ; CHECK: cont.us.us6.us:
54 ; CHECK-NEXT: br label [[FOR_END_SPLIT_US_US_US:%.*]]
55 ; CHECK: for.end.split.us.us.us:
56 ; CHECK-NEXT: br label [[FOR_END_US_US:%.*]]
57 ; CHECK: for.cond5.preheader.split.us.split.us7.us:
58 ; CHECK-NEXT: br label [[FOR_BODY7_US_US4_US:%.*]]
59 ; CHECK: for.inc11.split.us.us:
60 ; CHECK-NEXT: br label [[FOR_INC11_US:%.*]]
61 ; CHECK: for.cond.split.us.split.us11:
62 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_US_US9]]
63 ; CHECK: for.cond.split.us.split.us.split.us:
64 ; CHECK-NEXT: br label [[FOR_COND_SPLIT_US_SPLIT_US:%.*]]
65 ; CHECK: cleanup15.split.us.split.us:
66 ; CHECK-NEXT: br label [[CLEANUP15_SPLIT_US:%.*]]
68 ; CHECK-NEXT: br i1 [[FALSE]], label [[ENTRY_SPLIT_SPLIT_US:%.*]], label [[ENTRY_SPLIT_SPLIT:%.*]]
69 ; CHECK: entry.split.split.us:
70 ; CHECK-NEXT: br label [[FOR_COND_US12:%.*]]
71 ; CHECK: for.cond.us12:
72 ; CHECK-NEXT: br label [[FOR_COND_SPLIT_US:%.*]]
73 ; CHECK: for.cond.split.us:
74 ; CHECK-NEXT: br label [[FOR_COND_SPLIT_SPLIT_US_SPLIT_US:%.*]]
75 ; CHECK: for.cond.split.split.us.split.us:
76 ; CHECK-NEXT: br label [[FOR_COND_SPLIT_SPLIT_US:%.*]]
77 ; CHECK: entry.split.split:
78 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
80 ; CHECK-NEXT: br label [[FOR_COND_SPLIT:%.*]]
81 ; CHECK: for.cond.split.us.split.us:
82 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_US_US:%.*]]
83 ; CHECK: for.cond5.preheader.us.us:
84 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT_US_US_US:%.*]]
85 ; CHECK: for.cond5.preheader.split.us.us.us:
86 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT_US_SPLIT_US_SPLIT_US_SPLIT_US:%.*]]
87 ; CHECK: for.cond5.preheader.split.us.split.us.split.us.split.us:
88 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT_US_SPLIT_US_SPLIT_US:%.*]]
89 ; CHECK: cleanup15.split.us:
90 ; CHECK-NEXT: br label [[CLEANUP15:%.*]]
91 ; CHECK: for.cond5.preheader.split.us.split.us.split.us:
92 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT_US_SPLIT_US:%.*]]
93 ; CHECK: for.cond.split:
94 ; CHECK-NEXT: br label [[FOR_COND_SPLIT_SPLIT:%.*]]
95 ; CHECK: for.cond.split.split.us:
96 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_US8:%.*]]
97 ; CHECK: for.cond5.preheader.us8:
98 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT_US:%.*]]
99 ; CHECK: for.cond5.preheader.split.us:
100 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT_SPLIT_US_SPLIT_US:%.*]]
101 ; CHECK: for.cond5.preheader.split.split.us.split.us:
102 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT_SPLIT_US:%.*]]
103 ; CHECK: for.cond.split.split:
104 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER:%.*]]
105 ; CHECK: for.cond5.preheader:
106 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT:%.*]]
107 ; CHECK: for.cond5.preheader.split.us.split.us:
108 ; CHECK-NEXT: br label [[FOR_BODY7_US_US:%.*]]
109 ; CHECK: for.body7.us.us:
110 ; CHECK-NEXT: br label [[HANDLER_POINTER_OVERFLOW_US_US:%.*]]
111 ; CHECK: handler.pointer_overflow.us.us:
112 ; CHECK-NEXT: br label [[CONT_US_US:%.*]]
114 ; CHECK-NEXT: br label [[CONT_FOR_BODY7_CRIT_EDGE_US_US:%.*]]
115 ; CHECK: cont.for.body7_crit_edge.us.us:
116 ; CHECK-NEXT: br label [[FOR_BODY7_US_US]]
117 ; CHECK: for.cond5.preheader.split:
118 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER_SPLIT_SPLIT:%.*]]
119 ; CHECK: for.cond5.preheader.split.split.us:
120 ; CHECK-NEXT: br label [[FOR_BODY7_US1:%.*]]
121 ; CHECK: for.body7.us1:
122 ; CHECK-NEXT: br label [[CONT_US2:%.*]]
124 ; CHECK-NEXT: br label [[CONT_FOR_BODY7_CRIT_EDGE_US3:%.*]]
125 ; CHECK: cont.for.body7_crit_edge.us3:
126 ; CHECK-NEXT: br label [[FOR_BODY7_US1]]
127 ; CHECK: for.cond5.preheader.split.split:
128 ; CHECK-NEXT: br label [[FOR_BODY7:%.*]]
130 ; CHECK-NEXT: br label [[CONT:%.*]]
132 ; CHECK-NEXT: br label [[FOR_END_SPLIT:%.*]]
133 ; CHECK: for.end.split:
134 ; CHECK-NEXT: br label [[FOR_END:%.*]]
136 ; CHECK-NEXT: br i1 false, label [[FOR_INC8:%.*]], label [[CLEANUP15_SPLIT:%.*]]
138 ; CHECK-NEXT: br i1 false, label [[FOR_INC8_FOR_COND5_PREHEADER_CRIT_EDGE:%.*]], label [[FOR_INC11_SPLIT:%.*]]
139 ; CHECK: for.inc8.for.cond5.preheader_crit_edge:
140 ; CHECK-NEXT: br label [[FOR_COND5_PREHEADER]]
141 ; CHECK: for.inc11.split:
142 ; CHECK-NEXT: br label [[FOR_INC11:%.*]]
144 ; CHECK-NEXT: br label [[FOR_COND]]
145 ; CHECK: cleanup15.split:
146 ; CHECK-NEXT: br label [[CLEANUP15]]
148 ; CHECK-NEXT: ret i32 0
154 for.cond: ; preds = %for.inc11, %entry
155 br label %for.cond5.preheader
157 for.cond5.preheader: ; preds = %for.inc8.for.cond5.preheader_crit_edge, %for.cond
160 for.body7: ; preds = %cont.for.body7_crit_edge, %for.cond5.preheader
161 br i1 %not, label %handler.pointer_overflow, label %cont
163 handler.pointer_overflow: ; preds = %for.body7
166 cont: ; preds = %handler.pointer_overflow, %for.body7
167 br i1 %false, label %cont.for.body7_crit_edge, label %for.end
169 cont.for.body7_crit_edge: ; preds = %cont
172 for.end: ; preds = %cont
173 br i1 %false, label %for.inc8, label %cleanup15
175 for.inc8: ; preds = %for.end
176 br i1 %false, label %for.inc8.for.cond5.preheader_crit_edge, label %for.inc11
178 for.inc8.for.cond5.preheader_crit_edge: ; preds = %for.inc8
179 br label %for.cond5.preheader
181 for.inc11: ; preds = %for.inc8
184 cleanup15: ; preds = %for.end