@@ -125,6 +125,33 @@ bar.exit: ; preds = %for.cond.i, %for.bo
125
125
ret i32 0
126
126
}
127
127
128
+ ; PR18886: Indvars miscompile due to an incorrect max backedge taken count from SCEV.
129
+ ; CHECK-LABEL: @pr18886
130
+ ; CHECK: Loop %for.body: <multiple exits> Unpredictable backedge-taken count.
131
+ ; CHECK: Loop %for.body: max backedge-taken count is 3
132
+ @aa = global i64 0 , align 8
133
+
134
+ define i32 @pr18886 () {
135
+ entry:
136
+ store i64 -21 , i64* @aa , align 8
137
+ br label %for.body
138
+
139
+ for.body:
140
+ %storemerge1 = phi i64 [ -21 , %entry ], [ %add , %for.cond ]
141
+ %tobool = icmp eq i64 %storemerge1 , 0
142
+ %add = add nsw i64 %storemerge1 , 8
143
+ br i1 %tobool , label %return , label %for.cond
144
+
145
+ for.cond:
146
+ store i64 %add , i64* @aa , align 8
147
+ %cmp = icmp slt i64 %add , 9
148
+ br i1 %cmp , label %for.body , label %return
149
+
150
+ return:
151
+ %retval.0 = phi i32 [ 1 , %for.body ], [ 0 , %for.cond ]
152
+ ret i32 %retval.0
153
+ }
154
+
128
155
; Here we have a must-exit loop latch that is not computable and a
129
156
; may-exit early exit that can only have one non-exiting iteration
130
157
; before the check is forever skipped.
0 commit comments