1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='loop-mssa(indvars,indvars)' -S < %s | FileCheck %s
4 target triple = "x86_64-unknown-linux-gnu"
6 @c = external global i16, align 1
7 @a = external global i16, align 1
9 ; When we delete %c.promoted, we need to ensure we clear the getSCEVAtScope
10 ; cache or we'll crash trying to access loop disposition of the exit value
11 ; for the remaining IV.
15 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
17 ; CHECK-NEXT: br i1 false, label [[FOR_BODY:%.*]], label [[FOR_END4:%.*]]
19 ; CHECK-NEXT: br label [[FOR_BODY2:%.*]]
21 ; CHECK-NEXT: [[INC2:%.*]] = phi i16 [ undef, [[FOR_BODY]] ], [ [[INC:%.*]], [[FOR_BODY2]] ]
22 ; CHECK-NEXT: [[INC]] = add nuw nsw i16 [[INC2]], 1
23 ; CHECK-NEXT: store i16 [[INC]], ptr undef, align 1
24 ; CHECK-NEXT: br i1 true, label [[FOR_BODY2]], label [[CRIT_EDGE:%.*]]
26 ; CHECK-NEXT: [[INC_LCSSA:%.*]] = phi i16 [ [[INC]], [[FOR_BODY2]] ]
27 ; CHECK-NEXT: store i16 [[INC_LCSSA]], ptr @a, align 1
28 ; CHECK-NEXT: unreachable
30 ; CHECK-NEXT: ret void
35 for.cond: ; preds = %entry
36 br i1 false, label %for.body, label %for.end4
38 for.body: ; preds = %for.cond
39 %c.promoted = load i16, ptr @c, align 1
42 for.body2: ; preds = %for.body2, %for.body
43 %inc33 = phi i16 [ %c.promoted, %for.body ], [ %inc3, %for.body2 ]
44 %inc2 = phi i16 [ undef, %for.body ], [ %inc, %for.body2 ]
45 %inc = add nsw i16 %inc2, 1
46 store i16 %inc, ptr undef, align 1
47 %inc3 = add nsw i16 %inc33, 1
48 %tobool = icmp ne i16 %inc3, 0
49 br i1 %tobool, label %for.body2, label %crit_edge
51 crit_edge: ; preds = %for.body2
52 %inc.lcssa = phi i16 [ %inc, %for.body2 ]
53 store i16 %inc.lcssa, ptr @a, align 1
56 for.end4: ; preds = %for.cond