|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3 |
| 2 | +; RUN: opt < %s -passes=loop-vectorize,instcombine -enable-histogram-loop-vectorization -sve-gather-overhead=2 -sve-scatter-overhead=2 -epilogue-vectorization-minimum-VF=4 -debug-only=loop-vectorize -S 2>&1 | FileCheck %s |
| 3 | + |
| 4 | +target triple = "aarch64-unknown-linux-gnu" |
| 5 | + |
| 6 | +;; We don't currently support histograms in epilogue vectorization, so check for the debug message. |
| 7 | +; CHECK-LABEL: LV: Checking a loop in 'simple_histogram' |
| 8 | +; CHECK: LEV: Unable to vectorize epilogue because the loop is not a supported candidate. |
| 9 | + |
| 10 | +define void @simple_histogram(ptr noalias %buckets, ptr readonly %indices, i64 %N) #0 { |
| 11 | +; CHECK-LABEL: define void @simple_histogram( |
| 12 | +; CHECK-SAME: ptr noalias [[BUCKETS:%.*]], ptr readonly [[INDICES:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] { |
| 13 | +; CHECK-NEXT: entry: |
| 14 | +; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64() |
| 15 | +; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 2 |
| 16 | +; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ugt i64 [[TMP1]], [[N]] |
| 17 | +; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] |
| 18 | +; CHECK: vector.ph: |
| 19 | +; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64() |
| 20 | +; CHECK-NEXT: [[DOTNEG:%.*]] = mul nsw i64 [[TMP2]], -4 |
| 21 | +; CHECK-NEXT: [[N_VEC:%.*]] = and i64 [[DOTNEG]], [[N]] |
| 22 | +; CHECK-NEXT: [[TMP4:%.*]] = call i64 @llvm.vscale.i64() |
| 23 | +; CHECK-NEXT: [[TMP5:%.*]] = shl nuw nsw i64 [[TMP4]], 2 |
| 24 | +; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] |
| 25 | +; CHECK: vector.body: |
| 26 | +; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] |
| 27 | +; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds i32, ptr [[INDICES]], i64 [[INDEX]] |
| 28 | +; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <vscale x 4 x i32>, ptr [[TMP8]], align 4 |
| 29 | +; CHECK-NEXT: [[TMP9:%.*]] = zext <vscale x 4 x i32> [[WIDE_LOAD]] to <vscale x 4 x i64> |
| 30 | +; CHECK-NEXT: [[TMP10:%.*]] = getelementptr inbounds i32, ptr [[BUCKETS]], <vscale x 4 x i64> [[TMP9]] |
| 31 | +; CHECK-NEXT: call void @llvm.experimental.vector.histogram.add.nxv4p0.i32(<vscale x 4 x ptr> [[TMP10]], i32 1, <vscale x 4 x i1> shufflevector (<vscale x 4 x i1> insertelement (<vscale x 4 x i1> poison, i1 true, i64 0), <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer)) |
| 32 | +; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP5]] |
| 33 | +; CHECK-NEXT: [[TMP11:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]] |
| 34 | +; CHECK-NEXT: br i1 [[TMP11]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] |
| 35 | +; CHECK: middle.block: |
| 36 | +; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[N_VEC]], [[N]] |
| 37 | +; CHECK-NEXT: br i1 [[CMP_N]], label [[FOR_EXIT:%.*]], label [[SCALAR_PH]] |
| 38 | +; CHECK: scalar.ph: |
| 39 | +; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ] |
| 40 | +; CHECK-NEXT: br label [[FOR_BODY:%.*]] |
| 41 | +; CHECK: for.body: |
| 42 | +; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[FOR_BODY]] ] |
| 43 | +; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[INDICES]], i64 [[IV]] |
| 44 | +; CHECK-NEXT: [[TMP12:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 |
| 45 | +; CHECK-NEXT: [[IDXPROM1:%.*]] = zext i32 [[TMP12]] to i64 |
| 46 | +; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[BUCKETS]], i64 [[IDXPROM1]] |
| 47 | +; CHECK-NEXT: [[TMP13:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4 |
| 48 | +; CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP13]], 1 |
| 49 | +; CHECK-NEXT: store i32 [[INC]], ptr [[ARRAYIDX2]], align 4 |
| 50 | +; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1 |
| 51 | +; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]] |
| 52 | +; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_EXIT]], label [[FOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]] |
| 53 | +; CHECK: for.exit: |
| 54 | +; CHECK-NEXT: ret void |
| 55 | +; |
| 56 | +entry: |
| 57 | + br label %for.body |
| 58 | + |
| 59 | +for.body: |
| 60 | + %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] |
| 61 | + %arrayidx = getelementptr inbounds i32, ptr %indices, i64 %iv |
| 62 | + %0 = load i32, ptr %arrayidx, align 4 |
| 63 | + %idxprom1 = zext i32 %0 to i64 |
| 64 | + %arrayidx2 = getelementptr inbounds i32, ptr %buckets, i64 %idxprom1 |
| 65 | + %1 = load i32, ptr %arrayidx2, align 4 |
| 66 | + %inc = add nsw i32 %1, 1 |
| 67 | + store i32 %inc, ptr %arrayidx2, align 4 |
| 68 | + %iv.next = add nuw nsw i64 %iv, 1 |
| 69 | + %exitcond = icmp eq i64 %iv.next, %N |
| 70 | + br i1 %exitcond, label %for.exit, label %for.body |
| 71 | + |
| 72 | +for.exit: |
| 73 | + ret void |
| 74 | +} |
| 75 | + |
| 76 | +attributes #0 = { "target-features"="+sve2" vscale_range(1,16) } |
0 commit comments