1 ; RUN: opt -S -aarch64-sve-intrinsic-opts < %s | FileCheck %s
3 target triple = "aarch64-unknown-linux-gnu"
5 define void @pred_store_v2i8(<vscale x 16 x i1> %pred, ptr %addr) #0 {
6 ; CHECK-LABEL: @pred_store_v2i8(
7 ; CHECK-NEXT: store <vscale x 16 x i1> %pred, ptr %addr
9 %bitcast = bitcast <vscale x 16 x i1> %pred to <vscale x 2 x i8>
10 %extract = tail call <2 x i8> @llvm.vector.extract.v2i8.nxv2i8(<vscale x 2 x i8> %bitcast, i64 0)
11 store <2 x i8> %extract, ptr %addr, align 4
15 define void @pred_store_v4i8(<vscale x 16 x i1> %pred, ptr %addr) #1 {
16 ; CHECK-LABEL: @pred_store_v4i8(
17 ; CHECK-NEXT: store <vscale x 16 x i1> %pred, ptr %addr
18 ; CHECK-NEXT: ret void
19 %bitcast = bitcast <vscale x 16 x i1> %pred to <vscale x 2 x i8>
20 %extract = tail call <4 x i8> @llvm.vector.extract.v4i8.nxv2i8(<vscale x 2 x i8> %bitcast, i64 0)
21 store <4 x i8> %extract, ptr %addr, align 4
25 define void @pred_store_v8i8(<vscale x 16 x i1> %pred, ptr %addr) #2 {
26 ; CHECK-LABEL: @pred_store_v8i8(
27 ; CHECK-NEXT: store <vscale x 16 x i1> %pred, ptr %addr
28 ; CHECK-NEXT: ret void
29 %bitcast = bitcast <vscale x 16 x i1> %pred to <vscale x 2 x i8>
30 %extract = tail call <8 x i8> @llvm.vector.extract.v8i8.nxv2i8(<vscale x 2 x i8> %bitcast, i64 0)
31 store <8 x i8> %extract, ptr %addr, align 4
36 ; Check that too small of a vscale prevents optimization
37 define void @pred_store_neg1(<vscale x 16 x i1> %pred, ptr %addr) #0 {
38 ; CHECK-LABEL: @pred_store_neg1(
39 ; CHECK: call <4 x i8> @llvm.vector.extract
40 %bitcast = bitcast <vscale x 16 x i1> %pred to <vscale x 2 x i8>
41 %extract = tail call <4 x i8> @llvm.vector.extract.v4i8.nxv2i8(<vscale x 2 x i8> %bitcast, i64 0)
42 store <4 x i8> %extract, ptr %addr, align 4
46 ; Check that too large of a vscale prevents optimization
47 define void @pred_store_neg2(<vscale x 16 x i1> %pred, ptr %addr) #2 {
48 ; CHECK-LABEL: @pred_store_neg2(
49 ; CHECK: call <4 x i8> @llvm.vector.extract
50 %bitcast = bitcast <vscale x 16 x i1> %pred to <vscale x 2 x i8>
51 %extract = tail call <4 x i8> @llvm.vector.extract.v4i8.nxv2i8(<vscale x 2 x i8> %bitcast, i64 0)
52 store <4 x i8> %extract, ptr %addr, align 4
56 ; Check that a non-zero index prevents optimization
57 define void @pred_store_neg3(<vscale x 16 x i1> %pred, ptr %addr) #1 {
58 ; CHECK-LABEL: @pred_store_neg3(
59 ; CHECK: call <4 x i8> @llvm.vector.extract
60 %bitcast = bitcast <vscale x 16 x i1> %pred to <vscale x 2 x i8>
61 %extract = tail call <4 x i8> @llvm.vector.extract.v4i8.nxv2i8(<vscale x 2 x i8> %bitcast, i64 4)
62 store <4 x i8> %extract, ptr %addr, align 4
66 ; Check that differing vscale min/max prevents optimization
67 define void @pred_store_neg4(<vscale x 16 x i1> %pred, ptr %addr) #3 {
68 ; CHECK-LABEL: @pred_store_neg4(
69 ; CHECK: call <4 x i8> @llvm.vector.extract
70 %bitcast = bitcast <vscale x 16 x i1> %pred to <vscale x 2 x i8>
71 %extract = tail call <4 x i8> @llvm.vector.extract.v4i8.nxv2i8(<vscale x 2 x i8> %bitcast, i64 0)
72 store <4 x i8> %extract, ptr %addr, align 4
76 declare <2 x i8> @llvm.vector.extract.v2i8.nxv2i8(<vscale x 2 x i8>, i64)
77 declare <4 x i8> @llvm.vector.extract.v4i8.nxv2i8(<vscale x 2 x i8>, i64)
78 declare <8 x i8> @llvm.vector.extract.v8i8.nxv2i8(<vscale x 2 x i8>, i64)
80 attributes #0 = { "target-features"="+sve" vscale_range(1,1) }
81 attributes #1 = { "target-features"="+sve" vscale_range(2,2) }
82 attributes #2 = { "target-features"="+sve" vscale_range(4,4) }
83 attributes #3 = { "target-features"="+sve" vscale_range(2,4) }