1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -mtriple=x86_64-unknown -mattr=+avx -passes=slp-vectorizer | FileCheck %s
4 ;void phiUsingLoads(int *restrict A, int *restrict B) {
5 ; int tmp0, tmp1, tmp2, tmp3;
6 ; for (int i = 0; i < 100; i++) {
12 ; } else if (A[25] == 0) {
17 ; } else if (A[50] == 0) {
22 ; } else if (A[75] == 0) {
36 ; Function Attrs: norecurse nounwind uwtable
37 define void @phiUsingLoads(ptr noalias nocapture readonly %A, ptr noalias nocapture %B) local_unnamed_addr #0 {
38 ; CHECK-LABEL: @phiUsingLoads(
40 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A:%.*]], align 4
41 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[TMP0]], 0
42 ; CHECK-NEXT: [[ARRAYIDX12:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 25
43 ; CHECK-NEXT: [[ARRAYIDX28:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 50
44 ; CHECK-NEXT: [[ARRAYIDX44:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 75
45 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
46 ; CHECK: for.cond.cleanup:
47 ; CHECK-NEXT: store <4 x i32> [[TMP14:%.*]], ptr [[B:%.*]], align 4
48 ; CHECK-NEXT: ret void
50 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_INC:%.*]] ]
51 ; CHECK-NEXT: [[TMP2:%.*]] = phi <4 x i32> [ undef, [[ENTRY]] ], [ [[TMP14]], [[FOR_INC]] ]
52 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
54 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]
55 ; CHECK-NEXT: [[TMP4:%.*]] = load <4 x i32>, ptr [[ARRAYIDX2]], align 4
56 ; CHECK-NEXT: br label [[FOR_INC]]
58 ; CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr [[ARRAYIDX12]], align 4
59 ; CHECK-NEXT: [[CMP13:%.*]] = icmp eq i32 [[TMP5]], 0
60 ; CHECK-NEXT: br i1 [[CMP13]], label [[IF_THEN14:%.*]], label [[IF_ELSE27:%.*]]
62 ; CHECK-NEXT: [[ARRAYIDX17:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]
63 ; CHECK-NEXT: [[TMP7:%.*]] = load <4 x i32>, ptr [[ARRAYIDX17]], align 4
64 ; CHECK-NEXT: br label [[FOR_INC]]
66 ; CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[ARRAYIDX28]], align 4
67 ; CHECK-NEXT: [[CMP29:%.*]] = icmp eq i32 [[TMP8]], 0
68 ; CHECK-NEXT: br i1 [[CMP29]], label [[IF_THEN30:%.*]], label [[IF_ELSE43:%.*]]
70 ; CHECK-NEXT: [[ARRAYIDX33:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]
71 ; CHECK-NEXT: [[TMP10:%.*]] = load <4 x i32>, ptr [[ARRAYIDX33]], align 4
72 ; CHECK-NEXT: br label [[FOR_INC]]
74 ; CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr [[ARRAYIDX44]], align 4
75 ; CHECK-NEXT: [[CMP45:%.*]] = icmp eq i32 [[TMP11]], 0
76 ; CHECK-NEXT: br i1 [[CMP45]], label [[IF_THEN46:%.*]], label [[FOR_INC]]
78 ; CHECK-NEXT: [[ARRAYIDX49:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]
79 ; CHECK-NEXT: [[TMP13:%.*]] = load <4 x i32>, ptr [[ARRAYIDX49]], align 4
80 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP13]], <4 x i32> poison, <4 x i32> <i32 0, i32 1, i32 3, i32 2>
81 ; CHECK-NEXT: br label [[FOR_INC]]
83 ; CHECK-NEXT: [[TMP14]] = phi <4 x i32> [ [[TMP4]], [[IF_THEN]] ], [ [[TMP7]], [[IF_THEN14]] ], [ [[TMP10]], [[IF_THEN30]] ], [ [[SHUFFLE]], [[IF_THEN46]] ], [ [[TMP2]], [[IF_ELSE43]] ]
84 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
85 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 100
86 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]]
89 %0 = load i32, ptr %A, align 4
90 %cmp1 = icmp eq i32 %0, 0
91 %arrayidx12 = getelementptr inbounds i32, ptr %A, i64 25
92 %arrayidx28 = getelementptr inbounds i32, ptr %A, i64 50
93 %arrayidx44 = getelementptr inbounds i32, ptr %A, i64 75
96 for.cond.cleanup: ; preds = %for.inc
97 store i32 %tmp0.1, ptr %B, align 4
98 %arrayidx64 = getelementptr inbounds i32, ptr %B, i64 1
99 store i32 %tmp1.1, ptr %arrayidx64, align 4
100 %arrayidx65 = getelementptr inbounds i32, ptr %B, i64 2
101 store i32 %tmp2.1, ptr %arrayidx65, align 4
102 %arrayidx66 = getelementptr inbounds i32, ptr %B, i64 3
103 store i32 %tmp3.1, ptr %arrayidx66, align 4
106 for.body: ; preds = %for.inc, %entry
107 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.inc ]
108 %tmp3.0111 = phi i32 [ undef, %entry ], [ %tmp3.1, %for.inc ]
109 %tmp2.0110 = phi i32 [ undef, %entry ], [ %tmp2.1, %for.inc ]
110 %tmp1.0109 = phi i32 [ undef, %entry ], [ %tmp1.1, %for.inc ]
111 %tmp0.0108 = phi i32 [ undef, %entry ], [ %tmp0.1, %for.inc ]
112 br i1 %cmp1, label %if.then, label %if.else
114 if.then: ; preds = %for.body
115 %arrayidx2 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
116 %1 = load i32, ptr %arrayidx2, align 4
117 %2 = add nuw nsw i64 %indvars.iv, 1
118 %arrayidx5 = getelementptr inbounds i32, ptr %A, i64 %2
119 %3 = load i32, ptr %arrayidx5, align 4
120 %4 = add nuw nsw i64 %indvars.iv, 2
121 %arrayidx8 = getelementptr inbounds i32, ptr %A, i64 %4
122 %5 = load i32, ptr %arrayidx8, align 4
123 %6 = add nuw nsw i64 %indvars.iv, 3
124 %arrayidx11 = getelementptr inbounds i32, ptr %A, i64 %6
125 %7 = load i32, ptr %arrayidx11, align 4
128 if.else: ; preds = %for.body
129 %8 = load i32, ptr %arrayidx12, align 4
130 %cmp13 = icmp eq i32 %8, 0
131 br i1 %cmp13, label %if.then14, label %if.else27
133 if.then14: ; preds = %if.else
134 %arrayidx17 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
135 %9 = load i32, ptr %arrayidx17, align 4
136 %10 = add nuw nsw i64 %indvars.iv, 1
137 %arrayidx20 = getelementptr inbounds i32, ptr %A, i64 %10
138 %11 = load i32, ptr %arrayidx20, align 4
139 %12 = add nuw nsw i64 %indvars.iv, 2
140 %arrayidx23 = getelementptr inbounds i32, ptr %A, i64 %12
141 %13 = load i32, ptr %arrayidx23, align 4
142 %14 = add nuw nsw i64 %indvars.iv, 3
143 %arrayidx26 = getelementptr inbounds i32, ptr %A, i64 %14
144 %15 = load i32, ptr %arrayidx26, align 4
147 if.else27: ; preds = %if.else
148 %16 = load i32, ptr %arrayidx28, align 4
149 %cmp29 = icmp eq i32 %16, 0
150 br i1 %cmp29, label %if.then30, label %if.else43
152 if.then30: ; preds = %if.else27
153 %arrayidx33 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
154 %17 = load i32, ptr %arrayidx33, align 4
155 %18 = add nuw nsw i64 %indvars.iv, 1
156 %arrayidx36 = getelementptr inbounds i32, ptr %A, i64 %18
157 %19 = load i32, ptr %arrayidx36, align 4
158 %20 = add nuw nsw i64 %indvars.iv, 2
159 %arrayidx39 = getelementptr inbounds i32, ptr %A, i64 %20
160 %21 = load i32, ptr %arrayidx39, align 4
161 %22 = add nuw nsw i64 %indvars.iv, 3
162 %arrayidx42 = getelementptr inbounds i32, ptr %A, i64 %22
163 %23 = load i32, ptr %arrayidx42, align 4
166 if.else43: ; preds = %if.else27
167 %24 = load i32, ptr %arrayidx44, align 4
168 %cmp45 = icmp eq i32 %24, 0
169 br i1 %cmp45, label %if.then46, label %for.inc
171 if.then46: ; preds = %if.else43
172 %arrayidx49 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
173 %25 = load i32, ptr %arrayidx49, align 4
174 %26 = add nuw nsw i64 %indvars.iv, 1
175 %arrayidx52 = getelementptr inbounds i32, ptr %A, i64 %26
176 %27 = load i32, ptr %arrayidx52, align 4
177 %28 = add nuw nsw i64 %indvars.iv, 3
178 %arrayidx55 = getelementptr inbounds i32, ptr %A, i64 %28
179 %29 = load i32, ptr %arrayidx55, align 4
180 %30 = add nuw nsw i64 %indvars.iv, 2
181 %arrayidx58 = getelementptr inbounds i32, ptr %A, i64 %30
182 %31 = load i32, ptr %arrayidx58, align 4
185 for.inc: ; preds = %if.then, %if.then30, %if.else43, %if.then46, %if.then14
186 %tmp0.1 = phi i32 [ %1, %if.then ], [ %9, %if.then14 ], [ %17, %if.then30 ], [ %25, %if.then46 ], [ %tmp0.0108, %if.else43 ]
187 %tmp1.1 = phi i32 [ %3, %if.then ], [ %11, %if.then14 ], [ %19, %if.then30 ], [ %27, %if.then46 ], [ %tmp1.0109, %if.else43 ]
188 %tmp2.1 = phi i32 [ %5, %if.then ], [ %13, %if.then14 ], [ %21, %if.then30 ], [ %29, %if.then46 ], [ %tmp2.0110, %if.else43 ]
189 %tmp3.1 = phi i32 [ %7, %if.then ], [ %15, %if.then14 ], [ %23, %if.then30 ], [ %31, %if.then46 ], [ %tmp3.0111, %if.else43 ]
190 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
191 %exitcond = icmp eq i64 %indvars.iv.next, 100
192 br i1 %exitcond, label %for.cond.cleanup, label %for.body