Skip to content

Commit 195c01c

Browse files
Add test showing unwanted sinking of vector compare.
1 parent 20293eb commit 195c01c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -codegenprepare -S < %s -mtriple=aarch64-none-linux-gnu -mattr=+sve | FileCheck %s
3+
4+
define void @do_not_sink_scalable_vector_compare(ptr %a, ptr %b) {
5+
; CHECK-LABEL: define void @do_not_sink_scalable_vector_compare(
6+
; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]]) #[[ATTR0:[0-9]+]] {
7+
; CHECK-NEXT: [[ENTRY:.*]]:
8+
; CHECK-NEXT: [[STEP_VECTOR:%.*]] = call <vscale x 4 x i32> @llvm.stepvector.nxv4i32()
9+
; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
10+
; CHECK: [[VECTOR_BODY]]:
11+
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
12+
; CHECK-NEXT: [[TMP0:%.*]] = icmp ult <vscale x 4 x i32> [[STEP_VECTOR]], splat (i32 16)
13+
; CHECK-NEXT: [[SRC:%.*]] = getelementptr inbounds ptr, ptr [[A]], i64 [[INDEX]]
14+
; CHECK-NEXT: [[WIDE_LOAD:%.*]] = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32.p0(ptr [[SRC]], i32 4, <vscale x 4 x i1> [[TMP0]], <vscale x 4 x i32> poison)
15+
; CHECK-NEXT: [[DST:%.*]] = getelementptr inbounds ptr, ptr [[B]], i64 [[INDEX]]
16+
; CHECK-NEXT: call void @llvm.masked.store.nxv4i32.p0(<vscale x 4 x i32> [[WIDE_LOAD]], ptr [[DST]], i32 4, <vscale x 4 x i1> [[TMP0]])
17+
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
18+
; CHECK-NEXT: [[EXIT_COND:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024
19+
; CHECK-NEXT: br i1 [[EXIT_COND]], label %[[VECTOR_END:.*]], label %[[VECTOR_BODY]]
20+
; CHECK: [[VECTOR_END]]:
21+
; CHECK-NEXT: ret void
22+
;
23+
entry:
24+
%step.vector = call <vscale x 4 x i32> @llvm.stepvector()
25+
%mask = icmp ult <vscale x 4 x i32> %step.vector, splat (i32 16)
26+
br label %vector.body
27+
28+
vector.body:
29+
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
30+
%src = getelementptr inbounds ptr, ptr %a, i64 %index
31+
%wide.load = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32(ptr %src, i32 4, <vscale x 4 x i1> %mask, <vscale x 4 x i32> poison)
32+
%dst = getelementptr inbounds ptr, ptr %b, i64 %index
33+
call void @llvm.masked.store.nxv4i32(<vscale x 4 x i32> %wide.load, ptr %dst, i32 4, <vscale x 4 x i1> %mask)
34+
%index.next = add nuw i64 %index, 16
35+
%exit.cond = icmp eq i64 %index.next, 1024
36+
br i1 %exit.cond, label %vector.end, label %vector.body
37+
38+
vector.end:
39+
ret void
40+
}
41+

0 commit comments

Comments
 (0)