1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -loop-vectorize -mtriple=powerpc64le-unknown-unknown \
3 ; RUN: -force-target-max-vector-interleave=1 -mcpu=pwr9 < %s | FileCheck %s
4 define dso_local void @test(i32* %Arr, i32 signext %Len) {
7 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 0, [[LEN:%.*]]
8 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_COND_CLEANUP:%.*]]
9 ; CHECK: for.body.lr.ph:
10 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i32 [[LEN]], 4
11 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
13 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i32 [[LEN]], 4
14 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i32 [[LEN]], [[N_MOD_VF]]
15 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
17 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
18 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[INDEX]], 0
19 ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[TMP0]] to i64
20 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, i32* [[ARR:%.*]], i64 [[TMP1]]
21 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, i32* [[TMP2]], i32 0
22 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast i32* [[TMP3]] to <4 x i32>*
23 ; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <4 x i32>, <4 x i32>* [[TMP4]], align 4
24 ; CHECK-NEXT: [[TMP5:%.*]] = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> [[WIDE_LOAD]])
25 ; CHECK-NEXT: [[TMP6:%.*]] = sext i32 [[TMP0]] to i64
26 ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds i32, i32* [[ARR]], i64 [[TMP6]]
27 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds i32, i32* [[TMP7]], i32 0
28 ; CHECK-NEXT: [[TMP9:%.*]] = bitcast i32* [[TMP8]] to <4 x i32>*
29 ; CHECK-NEXT: store <4 x i32> [[TMP5]], <4 x i32>* [[TMP9]], align 4
30 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 4
31 ; CHECK-NEXT: [[TMP10:%.*]] = icmp eq i32 [[INDEX_NEXT]], [[N_VEC]]
32 ; CHECK-NEXT: br i1 [[TMP10]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
33 ; CHECK: middle.block:
34 ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i32 [[LEN]], [[N_VEC]]
35 ; CHECK-NEXT: br i1 [[CMP_N]], label [[FOR_COND_FOR_COND_CLEANUP_CRIT_EDGE:%.*]], label [[SCALAR_PH]]
37 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i32 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[FOR_BODY_LR_PH]] ]
38 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
39 ; CHECK: for.cond.for.cond.cleanup_crit_edge:
40 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
41 ; CHECK: for.cond.cleanup:
42 ; CHECK-NEXT: br label [[FOR_END:%.*]]
44 ; CHECK-NEXT: [[I_02:%.*]] = phi i32 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
45 ; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[I_02]] to i64
46 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[ARR]], i64 [[IDXPROM]]
47 ; CHECK-NEXT: [[TMP11:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
48 ; CHECK-NEXT: [[TMP12:%.*]] = call i32 @llvm.bswap.i32(i32 [[TMP11]])
49 ; CHECK-NEXT: [[IDXPROM1:%.*]] = sext i32 [[I_02]] to i64
50 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, i32* [[ARR]], i64 [[IDXPROM1]]
51 ; CHECK-NEXT: store i32 [[TMP12]], i32* [[ARRAYIDX2]], align 4
52 ; CHECK-NEXT: br label [[FOR_INC]]
54 ; CHECK-NEXT: [[INC]] = add nsw i32 [[I_02]], 1
55 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[LEN]]
56 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_FOR_COND_CLEANUP_CRIT_EDGE]], !llvm.loop [[LOOP2:![0-9]+]]
58 ; CHECK-NEXT: ret void
61 %cmp1 = icmp slt i32 0, %Len
62 br i1 %cmp1, label %for.body.lr.ph, label %for.cond.cleanup
64 for.body.lr.ph: ; preds = %entry
67 for.cond.for.cond.cleanup_crit_edge: ; preds = %for.inc
68 br label %for.cond.cleanup
70 for.cond.cleanup: ; preds = %for.cond.for.cond.cleanup_crit_edge, %entry
73 for.body: ; preds = %for.body.lr.ph, %for.inc
74 %i.02 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
75 %idxprom = sext i32 %i.02 to i64
76 %arrayidx = getelementptr inbounds i32, i32* %Arr, i64 %idxprom
77 %0 = load i32, i32* %arrayidx, align 4
78 %1 = call i32 @llvm.bswap.i32(i32 %0)
79 %idxprom1 = sext i32 %i.02 to i64
80 %arrayidx2 = getelementptr inbounds i32, i32* %Arr, i64 %idxprom1
81 store i32 %1, i32* %arrayidx2, align 4
84 for.inc: ; preds = %for.body
85 %inc = add nsw i32 %i.02, 1
86 %cmp = icmp slt i32 %inc, %Len
87 br i1 %cmp, label %for.body, label %for.cond.for.cond.cleanup_crit_edge
89 for.end: ; preds = %for.cond.cleanup
93 ; Function Attrs: nounwind readnone speculatable willreturn
94 declare i32 @llvm.bswap.i32(i32)