1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt < %s -mattr=+sve2 -passes=loop-vectorize,instcombine -enable-histogram-loop-vectorization -sve-gather-overhead=2 -sve-scatter-overhead=2 -force-vector-interleave=2 -force-vector-width=1 -debug-only=loop-vectorize -S 2>&1 | FileCheck %s
5 ;; Make sure we don't interleave a histogram when vectorization is disabled.
7 ; CHECK-LABEL: LV: Checking a loop in 'simple_histogram_forced_scalar_interleave'
8 ; CHECK: LV: Not interleaving without vectorization due to histogram operations.
10 define void @simple_histogram_forced_scalar_interleave(ptr noalias %buckets, ptr readonly %indices, i64 %N) {
11 ; CHECK-LABEL: define void @simple_histogram_forced_scalar_interleave(
12 ; CHECK-SAME: ptr noalias [[BUCKETS:%.*]], ptr readonly [[INDICES:%.*]], i64 [[N:%.*]]) {
14 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
16 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[FOR_BODY]] ]
17 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds nuw i32, ptr [[INDICES]], i64 [[IV]]
18 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
19 ; CHECK-NEXT: [[IDXPROM1:%.*]] = zext i32 [[TMP0]] to i64
20 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds nuw i32, ptr [[BUCKETS]], i64 [[IDXPROM1]]
21 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
22 ; CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP1]], 1
23 ; CHECK-NEXT: store i32 [[INC]], ptr [[ARRAYIDX2]], align 4
24 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
25 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
26 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_EXIT:%.*]], label [[FOR_BODY]]
28 ; CHECK-NEXT: ret void
34 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
35 %gep.indices = getelementptr inbounds i32, ptr %indices, i64 %iv
36 %l.idx = load i32, ptr %gep.indices, align 4
37 %idxprom1 = zext i32 %l.idx to i64
38 %gep.bucket = getelementptr inbounds i32, ptr %buckets, i64 %idxprom1
39 %l.bucket = load i32, ptr %gep.bucket, align 4
40 %inc = add nsw i32 %l.bucket, 1
41 store i32 %inc, ptr %gep.bucket, align 4
42 %iv.next = add nuw nsw i64 %iv, 1
43 %exitcond = icmp eq i64 %iv.next, %N
44 br i1 %exitcond, label %for.exit, label %for.body