Skip to content

Commit dd1f39a

Browse files
committed
Extra tests
1 parent f1d84a2 commit dd1f39a

File tree

3 files changed

+173
-0
lines changed

3 files changed

+173
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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) }
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 -debug-only=loop-vectorize -S 2>&1 | FileCheck %s
3+
4+
;; Make sure we don't interleave a histogram when vectorization is disabled.
5+
6+
; CHECK-LABEL: LV: Checking a loop in 'simple_histogram_forced_scalar_interleave'
7+
; CHECK: LV: Not interleaving without vectorization due to histogram operations.
8+
9+
define void @simple_histogram_forced_scalar_interleave(ptr noalias %buckets, ptr readonly %indices, i64 %N) #0 {
10+
; CHECK-LABEL: define void @simple_histogram_forced_scalar_interleave(
11+
; CHECK-SAME: ptr noalias [[BUCKETS:%.*]], ptr readonly [[INDICES:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
12+
; CHECK-NEXT: entry:
13+
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
14+
; CHECK: for.body:
15+
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[FOR_BODY]] ]
16+
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[INDICES]], i64 [[IV]]
17+
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
18+
; CHECK-NEXT: [[IDXPROM1:%.*]] = zext i32 [[TMP0]] to i64
19+
; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[BUCKETS]], i64 [[IDXPROM1]]
20+
; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
21+
; CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP1]], 1
22+
; CHECK-NEXT: store i32 [[INC]], ptr [[ARRAYIDX2]], align 4
23+
; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
24+
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
25+
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_EXIT:%.*]], label [[FOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
26+
; CHECK: for.exit:
27+
; CHECK-NEXT: ret void
28+
;
29+
entry:
30+
br label %for.body
31+
32+
for.body:
33+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
34+
%arrayidx = getelementptr inbounds i32, ptr %indices, i64 %iv
35+
%0 = load i32, ptr %arrayidx, align 4
36+
%idxprom1 = zext i32 %0 to i64
37+
%arrayidx2 = getelementptr inbounds i32, ptr %buckets, i64 %idxprom1
38+
%1 = load i32, ptr %arrayidx2, align 4
39+
%inc = add nsw i32 %1, 1
40+
store i32 %inc, ptr %arrayidx2, align 4
41+
%iv.next = add nuw nsw i64 %iv, 1
42+
%exitcond = icmp eq i64 %iv.next, %N
43+
br i1 %exitcond, label %for.exit, label %for.body, !llvm.loop !0
44+
45+
for.exit:
46+
ret void
47+
}
48+
49+
attributes #0 = { "target-features"="+sve2" vscale_range(1,16) }
50+
51+
!0 = distinct !{!0, !1, !2}
52+
!1 = !{!"llvm.loop.interleave.count", i32 2}
53+
!2 = !{!"llvm.loop.vectorize.width", i32 1}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 -S | FileCheck %s
3+
4+
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
5+
6+
define void @simple_histogram(ptr noalias %buckets, ptr readonly %indices, i64 %N) #0 {
7+
; CHECK-LABEL: define void @simple_histogram(
8+
; CHECK-SAME: ptr noalias [[BUCKETS:%.*]], ptr readonly [[INDICES:%.*]], i64 [[N:%.*]]) {
9+
; CHECK-NEXT: entry:
10+
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
11+
; CHECK: for.body:
12+
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[FOR_BODY]] ]
13+
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[INDICES]], i64 [[IV]]
14+
; CHECK-NEXT: [[TMP12:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
15+
; CHECK-NEXT: [[IDXPROM1:%.*]] = zext i32 [[TMP12]] to i64
16+
; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[BUCKETS]], i64 [[IDXPROM1]]
17+
; CHECK-NEXT: [[TMP13:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
18+
; CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP13]], 1
19+
; CHECK-NEXT: store i32 [[INC]], ptr [[ARRAYIDX2]], align 4
20+
; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
21+
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
22+
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_EXIT:%.*]], label [[FOR_BODY]]
23+
; CHECK: for.exit:
24+
; CHECK-NEXT: ret void
25+
;
26+
entry:
27+
br label %for.body
28+
29+
for.body:
30+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
31+
%arrayidx = getelementptr inbounds i32, ptr %indices, i64 %iv
32+
%0 = load i32, ptr %arrayidx, align 4
33+
%idxprom1 = zext i32 %0 to i64
34+
%arrayidx2 = getelementptr inbounds i32, ptr %buckets, i64 %idxprom1
35+
%1 = load i32, ptr %arrayidx2, align 4
36+
%inc = add nsw i32 %1, 1
37+
store i32 %inc, ptr %arrayidx2, align 4
38+
%iv.next = add nuw nsw i64 %iv, 1
39+
%exitcond = icmp eq i64 %iv.next, %N
40+
br i1 %exitcond, label %for.exit, label %for.body
41+
42+
for.exit:
43+
ret void
44+
}

0 commit comments

Comments
 (0)