1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='loop-vectorize,loop-versioning' -S %s | FileCheck %s
4 @glob.1 = external global [100 x double]
5 @glob.2 = external global [100 x double]
7 ; Test for PR57825 to make sure LAA is properly invalidated after versioning
9 define void @test(ptr %arg, i64 %arg1) {
12 ; CHECK-NEXT: br label [[INNER_1_LVER_CHECK:%.*]]
13 ; CHECK: inner.1.lver.check:
14 ; CHECK-NEXT: [[PTR_PHI:%.*]] = phi ptr [ [[ARG:%.*]], [[BB:%.*]] ], [ @glob.1, [[OUTER_LATCH:%.*]] ]
15 ; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr double, ptr [[PTR_PHI]], i64 3
16 ; CHECK-NEXT: [[IDENT_CHECK:%.*]] = icmp ne i64 [[ARG1:%.*]], 1
17 ; CHECK-NEXT: br i1 [[IDENT_CHECK]], label [[INNER_1_PH_LVER_ORIG:%.*]], label [[INNER_1_PH:%.*]]
18 ; CHECK: inner.1.ph.lver.orig:
19 ; CHECK-NEXT: br label [[INNER_1_LVER_ORIG:%.*]]
20 ; CHECK: inner.1.lver.orig:
21 ; CHECK-NEXT: [[IV_1_LVER_ORIG:%.*]] = phi i64 [ 0, [[INNER_1_PH_LVER_ORIG]] ], [ [[IV_NEXT_LVER_ORIG:%.*]], [[INNER_1_LVER_ORIG]] ]
22 ; CHECK-NEXT: [[PTR_IV_1_LVER_ORIG:%.*]] = phi ptr [ @glob.2, [[INNER_1_PH_LVER_ORIG]] ], [ [[PTR_IV_1_NEXT_LVER_ORIG:%.*]], [[INNER_1_LVER_ORIG]] ]
23 ; CHECK-NEXT: [[TMP25_LVER_ORIG:%.*]] = mul nuw nsw i64 [[IV_1_LVER_ORIG]], [[ARG1]]
24 ; CHECK-NEXT: [[GEP_2_LVER_ORIG:%.*]] = getelementptr inbounds double, ptr [[GEP_1]], i64 [[TMP25_LVER_ORIG]]
25 ; CHECK-NEXT: store double 0.000000e+00, ptr [[GEP_2_LVER_ORIG]], align 8
26 ; CHECK-NEXT: [[GEP_3_LVER_ORIG:%.*]] = getelementptr double, ptr [[PTR_PHI]], i64 [[TMP25_LVER_ORIG]]
27 ; CHECK-NEXT: [[GEP_4_LVER_ORIG:%.*]] = getelementptr double, ptr [[GEP_3_LVER_ORIG]], i64 2
28 ; CHECK-NEXT: [[TMP29_LVER_ORIG:%.*]] = load double, ptr [[GEP_4_LVER_ORIG]], align 8
29 ; CHECK-NEXT: [[PTR_IV_1_NEXT_LVER_ORIG]] = getelementptr inbounds double, ptr [[PTR_IV_1_LVER_ORIG]], i64 1
30 ; CHECK-NEXT: [[IV_NEXT_LVER_ORIG]] = add nuw nsw i64 [[IV_1_LVER_ORIG]], 1
31 ; CHECK-NEXT: [[C_1_LVER_ORIG:%.*]] = icmp eq i64 [[IV_1_LVER_ORIG]], 1
32 ; CHECK-NEXT: br i1 [[C_1_LVER_ORIG]], label [[INNER_1_EXIT_LOOPEXIT:%.*]], label [[INNER_1_LVER_ORIG]]
34 ; CHECK-NEXT: br label [[INNER_1:%.*]]
36 ; CHECK-NEXT: [[IV_1:%.*]] = phi i64 [ 0, [[INNER_1_PH]] ], [ [[IV_NEXT:%.*]], [[INNER_1]] ]
37 ; CHECK-NEXT: [[PTR_IV_1:%.*]] = phi ptr [ @glob.2, [[INNER_1_PH]] ], [ [[PTR_IV_1_NEXT:%.*]], [[INNER_1]] ]
38 ; CHECK-NEXT: [[TMP25:%.*]] = mul nuw nsw i64 [[IV_1]], [[ARG1]]
39 ; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr inbounds double, ptr [[GEP_1]], i64 [[TMP25]]
40 ; CHECK-NEXT: store double 0.000000e+00, ptr [[GEP_2]], align 8
41 ; CHECK-NEXT: [[GEP_3:%.*]] = getelementptr double, ptr [[PTR_PHI]], i64 [[TMP25]]
42 ; CHECK-NEXT: [[GEP_4:%.*]] = getelementptr double, ptr [[GEP_3]], i64 2
43 ; CHECK-NEXT: [[TMP29:%.*]] = load double, ptr [[GEP_4]], align 8
44 ; CHECK-NEXT: [[PTR_IV_1_NEXT]] = getelementptr inbounds double, ptr [[PTR_IV_1]], i64 1
45 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV_1]], 1
46 ; CHECK-NEXT: [[C_1:%.*]] = icmp eq i64 [[IV_1]], 1
47 ; CHECK-NEXT: br i1 [[C_1]], label [[INNER_1_EXIT_LOOPEXIT1:%.*]], label [[INNER_1]]
48 ; CHECK: inner.1.exit.loopexit:
49 ; CHECK-NEXT: [[LCSSA_PTR_IV_1_PH:%.*]] = phi ptr [ [[PTR_IV_1_LVER_ORIG]], [[INNER_1_LVER_ORIG]] ]
50 ; CHECK-NEXT: br label [[INNER_1_EXIT:%.*]]
51 ; CHECK: inner.1.exit.loopexit1:
52 ; CHECK-NEXT: [[LCSSA_PTR_IV_1_PH2:%.*]] = phi ptr [ [[PTR_IV_1]], [[INNER_1]] ]
53 ; CHECK-NEXT: br label [[INNER_1_EXIT]]
54 ; CHECK: inner.1.exit:
55 ; CHECK-NEXT: [[LCSSA_PTR_IV_1:%.*]] = phi ptr [ [[LCSSA_PTR_IV_1_PH]], [[INNER_1_EXIT_LOOPEXIT]] ], [ [[LCSSA_PTR_IV_1_PH2]], [[INNER_1_EXIT_LOOPEXIT1]] ]
56 ; CHECK-NEXT: [[GEP_5:%.*]] = getelementptr inbounds double, ptr [[LCSSA_PTR_IV_1]], i64 1
57 ; CHECK-NEXT: br label [[INNER_2:%.*]]
59 ; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[INDVAR_NEXT:%.*]], [[INNER_2]] ], [ 0, [[INNER_1_EXIT]] ]
60 ; CHECK-NEXT: [[PTR_IV_2:%.*]] = phi ptr [ [[GEP_5]], [[INNER_1_EXIT]] ], [ [[PTR_IV_2_NEXT:%.*]], [[INNER_2]] ]
61 ; CHECK-NEXT: [[PTR_IV_2_NEXT]] = getelementptr inbounds double, ptr [[PTR_IV_2]], i64 1
62 ; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
63 ; CHECK-NEXT: br i1 false, label [[INNER_3_LVER_CHECK:%.*]], label [[INNER_2]]
64 ; CHECK: inner.3.lver.check:
65 ; CHECK-NEXT: [[INDVAR_LCSSA:%.*]] = phi i64 [ [[INDVAR]], [[INNER_2]] ]
66 ; CHECK-NEXT: [[LCSSA_PTR_IV_2:%.*]] = phi ptr [ [[PTR_IV_2]], [[INNER_2]] ]
67 ; CHECK-NEXT: [[GEP_6:%.*]] = getelementptr inbounds double, ptr [[PTR_PHI]], i64 1
68 ; CHECK-NEXT: [[GEP_7:%.*]] = getelementptr inbounds double, ptr [[LCSSA_PTR_IV_2]], i64 1
69 ; CHECK-NEXT: [[TMP0:%.*]] = shl i64 [[INDVAR_LCSSA]], 3
70 ; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[TMP0]], 24
71 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[LCSSA_PTR_IV_1]], i64 [[TMP1]]
72 ; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult ptr [[GEP_7]], [[GEP_1]]
73 ; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult ptr [[PTR_PHI]], [[SCEVGEP]]
74 ; CHECK-NEXT: [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
75 ; CHECK-NEXT: br i1 [[FOUND_CONFLICT]], label [[INNER_3_PH_LVER_ORIG:%.*]], label [[INNER_3_PH:%.*]]
76 ; CHECK: inner.3.ph.lver.orig:
77 ; CHECK-NEXT: br label [[INNER_3_LVER_ORIG:%.*]]
78 ; CHECK: inner.3.lver.orig:
79 ; CHECK-NEXT: [[IV_2_LVER_ORIG:%.*]] = phi i64 [ 0, [[INNER_3_PH_LVER_ORIG]] ], [ [[IV_2_NEXT_LVER_ORIG:%.*]], [[INNER_3_LVER_ORIG]] ]
80 ; CHECK-NEXT: [[GEP_8_LVER_ORIG:%.*]] = getelementptr inbounds double, ptr [[GEP_6]], i64 [[IV_2_LVER_ORIG]]
81 ; CHECK-NEXT: store double 0.000000e+00, ptr [[GEP_7]], align 8
82 ; CHECK-NEXT: store double 0.000000e+00, ptr [[GEP_8_LVER_ORIG]], align 8
83 ; CHECK-NEXT: [[GEP_9_LVER_ORIG:%.*]] = getelementptr double, ptr [[PTR_PHI]], i64 [[IV_2_LVER_ORIG]]
84 ; CHECK-NEXT: [[TMP18_LVER_ORIG:%.*]] = load double, ptr [[GEP_9_LVER_ORIG]], align 8
85 ; CHECK-NEXT: [[IV_2_NEXT_LVER_ORIG]] = add nuw nsw i64 [[IV_2_LVER_ORIG]], 1
86 ; CHECK-NEXT: [[C_2_LVER_ORIG:%.*]] = icmp eq i64 [[IV_2_LVER_ORIG]], 1
87 ; CHECK-NEXT: br i1 [[C_2_LVER_ORIG]], label [[OUTER_LATCH_LOOPEXIT:%.*]], label [[INNER_3_LVER_ORIG]]
89 ; CHECK-NEXT: br label [[INNER_3:%.*]]
91 ; CHECK-NEXT: [[IV_2:%.*]] = phi i64 [ 0, [[INNER_3_PH]] ], [ [[IV_2_NEXT:%.*]], [[INNER_3]] ]
92 ; CHECK-NEXT: [[GEP_8:%.*]] = getelementptr inbounds double, ptr [[GEP_6]], i64 [[IV_2]]
93 ; CHECK-NEXT: store double 0.000000e+00, ptr [[GEP_7]], align 8, !alias.scope !0, !noalias !3
94 ; CHECK-NEXT: store double 0.000000e+00, ptr [[GEP_8]], align 8, !alias.scope !3
95 ; CHECK-NEXT: [[GEP_9:%.*]] = getelementptr double, ptr [[PTR_PHI]], i64 [[IV_2]]
96 ; CHECK-NEXT: [[TMP18:%.*]] = load double, ptr [[GEP_9]], align 8, !alias.scope !3
97 ; CHECK-NEXT: [[IV_2_NEXT]] = add nuw nsw i64 [[IV_2]], 1
98 ; CHECK-NEXT: [[C_2:%.*]] = icmp eq i64 [[IV_2]], 1
99 ; CHECK-NEXT: br i1 [[C_2]], label [[OUTER_LATCH_LOOPEXIT3:%.*]], label [[INNER_3]]
100 ; CHECK: outer.latch.loopexit:
101 ; CHECK-NEXT: br label [[OUTER_LATCH]]
102 ; CHECK: outer.latch.loopexit3:
103 ; CHECK-NEXT: br label [[OUTER_LATCH]]
104 ; CHECK: outer.latch:
105 ; CHECK-NEXT: br label [[INNER_1_LVER_CHECK]]
108 br label %outer.header
110 outer.header: ; preds = %bb21, %bb
111 %ptr.phi = phi ptr [ %arg, %bb ], [ @glob.1, %outer.latch ]
112 %gep.1 = getelementptr inbounds double, ptr %ptr.phi, i64 3
116 %iv.1 = phi i64 [ 0, %outer.header ], [ %iv.next, %inner.1 ]
117 %ptr.iv.1 = phi ptr [ @glob.2, %outer.header ], [ %ptr.iv.1.next, %inner.1 ]
118 %tmp25 = mul nuw nsw i64 %iv.1, %arg1
119 %gep.2 = getelementptr inbounds double, ptr %gep.1, i64 %tmp25
120 store double 0.000000e+00, ptr %gep.2, align 8
121 %gep.3 = getelementptr double, ptr %ptr.phi, i64 %tmp25
122 %gep.4 = getelementptr double, ptr %gep.3, i64 2
123 %tmp29 = load double, ptr %gep.4, align 8
124 %ptr.iv.1.next = getelementptr inbounds double, ptr %ptr.iv.1, i64 1
125 %iv.next = add nuw nsw i64 %iv.1, 1
126 %c.1 = icmp eq i64 %iv.1, 1
127 br i1 %c.1, label %inner.1.exit, label %inner.1
129 inner.1.exit: ; preds = %bb22
130 %lcssa.ptr.iv.1 = phi ptr [ %ptr.iv.1, %inner.1 ]
131 %gep.5 = getelementptr inbounds double, ptr %lcssa.ptr.iv.1, i64 1
135 %ptr.iv.2 = phi ptr [ %gep.5, %inner.1.exit ], [ %ptr.iv.2.next, %inner.2 ]
136 %ptr.iv.2.next = getelementptr inbounds double, ptr %ptr.iv.2, i64 1
137 br i1 false, label %inner.2.exit, label %inner.2
140 %lcssa.ptr.iv.2 = phi ptr [ %ptr.iv.2, %inner.2 ]
141 %gep.6 = getelementptr inbounds double, ptr %ptr.phi, i64 1
142 %gep.7 = getelementptr inbounds double, ptr %lcssa.ptr.iv.2, i64 1
145 inner.3: ; preds = %bb14, %bb10
146 %iv.2 = phi i64 [ 0, %inner.2.exit ], [ %iv.2.next, %inner.3 ]
147 %gep.8 = getelementptr inbounds double, ptr %gep.6, i64 %iv.2
148 store double 0.000000e+00, ptr %gep.7, align 8
149 store double 0.000000e+00, ptr %gep.8, align 8
150 %gep.9 = getelementptr double, ptr %ptr.phi, i64 %iv.2
151 %tmp18 = load double, ptr %gep.9, align 8
152 %iv.2.next = add nuw nsw i64 %iv.2, 1
153 %c.2 = icmp eq i64 %iv.2, 1
154 br i1 %c.2, label %outer.latch, label %inner.3
157 br label %outer.header