1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -loop-flatten -verify-loop-info -verify-dom-info -verify-scev -verify | FileCheck %s
5 ; Previously we had an assertion that the incoming value from the
6 ; loop latch (%inc) is the same as the operator in the compare
7 ; statement (%0). This does not necessarily hold as demonstrated
8 ; in the following case.
10 define dso_local void @main() {
13 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
15 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
17 ; CHECK-NEXT: [[A_03:%.*]] = phi i32 [ 0, [[FOR_COND]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
18 ; CHECK-NEXT: br label [[FOR_INC]]
20 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[A_03]], 1
21 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP0]], 10
22 ; CHECK-NEXT: [[INC]] = add nsw i32 [[A_03]], 1
23 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
25 ; CHECK-NEXT: br label [[FOR_COND]]
30 for.cond: ; preds = %for.end, %entry
33 for.body: ; preds = %for.inc, %for.cond
34 %a.03 = phi i32 [ 0, %for.cond ], [ %inc, %for.inc ]
37 for.inc: ; preds = %for.body
39 %cmp = icmp slt i32 %0, 10
40 %inc = add nsw i32 %a.03, 1
41 br i1 %cmp, label %for.body, label %for.end
43 for.end: ; preds = %for.inc