236
|
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
2 ; RUN: opt -passes='loop-mssa(indvars,indvars)' -S < %s | FileCheck %s
|
|
3
|
|
4 target triple = "x86_64-unknown-linux-gnu"
|
|
5
|
|
6 @c = external global i16, align 1
|
|
7 @a = external global i16, align 1
|
|
8
|
|
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.
|
|
12 define void @f() {
|
|
13 ; CHECK-LABEL: @f(
|
|
14 ; CHECK-NEXT: entry:
|
|
15 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
|
|
16 ; CHECK: for.cond:
|
|
17 ; CHECK-NEXT: br i1 false, label [[FOR_BODY:%.*]], label [[FOR_END4:%.*]]
|
|
18 ; CHECK: for.body:
|
|
19 ; CHECK-NEXT: br label [[FOR_BODY2:%.*]]
|
|
20 ; CHECK: for.body2:
|
|
21 ; CHECK-NEXT: [[INC2:%.*]] = phi i16 [ undef, [[FOR_BODY]] ], [ [[INC:%.*]], [[FOR_BODY2]] ]
|
|
22 ; CHECK-NEXT: [[INC]] = add nuw nsw i16 [[INC2]], 1
|
252
|
23 ; CHECK-NEXT: store i16 [[INC]], ptr undef, align 1
|
236
|
24 ; CHECK-NEXT: br i1 true, label [[FOR_BODY2]], label [[CRIT_EDGE:%.*]]
|
|
25 ; CHECK: crit_edge:
|
|
26 ; CHECK-NEXT: [[INC_LCSSA:%.*]] = phi i16 [ [[INC]], [[FOR_BODY2]] ]
|
252
|
27 ; CHECK-NEXT: store i16 [[INC_LCSSA]], ptr @a, align 1
|
236
|
28 ; CHECK-NEXT: unreachable
|
|
29 ; CHECK: for.end4:
|
|
30 ; CHECK-NEXT: ret void
|
|
31 ;
|
|
32 entry:
|
|
33 br label %for.cond
|
|
34
|
|
35 for.cond: ; preds = %entry
|
|
36 br i1 false, label %for.body, label %for.end4
|
|
37
|
|
38 for.body: ; preds = %for.cond
|
252
|
39 %c.promoted = load i16, ptr @c, align 1
|
236
|
40 br label %for.body2
|
|
41
|
|
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
|
252
|
46 store i16 %inc, ptr undef, align 1
|
236
|
47 %inc3 = add nsw i16 %inc33, 1
|
|
48 %tobool = icmp ne i16 %inc3, 0
|
|
49 br i1 %tobool, label %for.body2, label %crit_edge
|
|
50
|
|
51 crit_edge: ; preds = %for.body2
|
|
52 %inc.lcssa = phi i16 [ %inc, %for.body2 ]
|
252
|
53 store i16 %inc.lcssa, ptr @a, align 1
|
236
|
54 unreachable
|
|
55
|
|
56 for.end4: ; preds = %for.cond
|
|
57 ret void
|
|
58 }
|