1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=riscv64 -mattr=+v | FileCheck %s
4 declare <2 x i64> @llvm.sshl.sat.v2i64(<2 x i64>, <2 x i64>)
5 declare <4 x i32> @llvm.sshl.sat.v4i32(<4 x i32>, <4 x i32>)
6 declare <8 x i16> @llvm.sshl.sat.v8i16(<8 x i16>, <8 x i16>)
7 declare <16 x i8> @llvm.sshl.sat.v16i8(<16 x i8>, <16 x i8>)
9 define <2 x i64> @vec_v2i64(<2 x i64> %x, <2 x i64> %y) nounwind {
10 ; CHECK-LABEL: vec_v2i64:
12 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
13 ; CHECK-NEXT: vmsle.vi v0, v8, -1
14 ; CHECK-NEXT: li a0, -1
15 ; CHECK-NEXT: vsll.vv v10, v8, v9
16 ; CHECK-NEXT: srli a1, a0, 1
17 ; CHECK-NEXT: vsra.vv v9, v10, v9
18 ; CHECK-NEXT: vmsne.vv v8, v8, v9
19 ; CHECK-NEXT: vmv.v.x v9, a1
20 ; CHECK-NEXT: slli a0, a0, 63
21 ; CHECK-NEXT: vmerge.vxm v9, v9, a0, v0
22 ; CHECK-NEXT: vmv.v.v v0, v8
23 ; CHECK-NEXT: vmerge.vvm v8, v10, v9, v0
25 %tmp = call <2 x i64> @llvm.sshl.sat.v2i64(<2 x i64> %x, <2 x i64> %y)
29 define <4 x i32> @vec_v4i32(<4 x i32> %x, <4 x i32> %y) nounwind {
30 ; CHECK-LABEL: vec_v4i32:
32 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
33 ; CHECK-NEXT: vmsle.vi v0, v8, -1
34 ; CHECK-NEXT: lui a0, 524288
35 ; CHECK-NEXT: vsll.vv v10, v8, v9
36 ; CHECK-NEXT: addi a1, a0, -1
37 ; CHECK-NEXT: vsra.vv v9, v10, v9
38 ; CHECK-NEXT: vmsne.vv v8, v8, v9
39 ; CHECK-NEXT: vmv.v.x v9, a1
40 ; CHECK-NEXT: vmerge.vxm v9, v9, a0, v0
41 ; CHECK-NEXT: vmv.v.v v0, v8
42 ; CHECK-NEXT: vmerge.vvm v8, v10, v9, v0
44 %tmp = call <4 x i32> @llvm.sshl.sat.v4i32(<4 x i32> %x, <4 x i32> %y)
48 define <8 x i16> @vec_v8i16(<8 x i16> %x, <8 x i16> %y) nounwind {
49 ; CHECK-LABEL: vec_v8i16:
51 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
52 ; CHECK-NEXT: vmsle.vi v0, v8, -1
53 ; CHECK-NEXT: lui a0, 8
54 ; CHECK-NEXT: vsll.vv v10, v8, v9
55 ; CHECK-NEXT: addi a1, a0, -1
56 ; CHECK-NEXT: vsra.vv v9, v10, v9
57 ; CHECK-NEXT: vmsne.vv v8, v8, v9
58 ; CHECK-NEXT: vmv.v.x v9, a1
59 ; CHECK-NEXT: vmerge.vxm v9, v9, a0, v0
60 ; CHECK-NEXT: vmv.v.v v0, v8
61 ; CHECK-NEXT: vmerge.vvm v8, v10, v9, v0
63 %tmp = call <8 x i16> @llvm.sshl.sat.v8i16(<8 x i16> %x, <8 x i16> %y)
67 define <16 x i8> @vec_v16i8(<16 x i8> %x, <16 x i8> %y) nounwind {
68 ; CHECK-LABEL: vec_v16i8:
70 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
71 ; CHECK-NEXT: vmsle.vi v0, v8, -1
72 ; CHECK-NEXT: li a0, 127
73 ; CHECK-NEXT: vsll.vv v10, v8, v9
74 ; CHECK-NEXT: vsra.vv v9, v10, v9
75 ; CHECK-NEXT: vmsne.vv v8, v8, v9
76 ; CHECK-NEXT: vmv.v.x v9, a0
77 ; CHECK-NEXT: li a0, 128
78 ; CHECK-NEXT: vmerge.vxm v9, v9, a0, v0
79 ; CHECK-NEXT: vmv.v.v v0, v8
80 ; CHECK-NEXT: vmerge.vvm v8, v10, v9, v0
82 %tmp = call <16 x i8> @llvm.sshl.sat.v16i8(<16 x i8> %x, <16 x i8> %y)
86 declare <vscale x 2 x i64> @llvm.sshl.sat.nxv2i64(<vscale x 2 x i64>, <vscale x 2 x i64>)
87 declare <vscale x 4 x i32> @llvm.sshl.sat.nxv4i32(<vscale x 4 x i32>, <vscale x 4 x i32>)
88 declare <vscale x 8 x i16> @llvm.sshl.sat.nxv8i16(<vscale x 8 x i16>, <vscale x 8 x i16>)
89 declare <vscale x 16 x i8> @llvm.sshl.sat.nxv16i8(<vscale x 16 x i8>, <vscale x 16 x i8>)
91 define <vscale x 2 x i64> @vec_nxv2i64(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y) nounwind {
92 ; CHECK-LABEL: vec_nxv2i64:
94 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
95 ; CHECK-NEXT: vmsle.vi v0, v8, -1
96 ; CHECK-NEXT: li a0, -1
97 ; CHECK-NEXT: vsll.vv v12, v8, v10
98 ; CHECK-NEXT: srli a1, a0, 1
99 ; CHECK-NEXT: vsra.vv v14, v12, v10
100 ; CHECK-NEXT: vmsne.vv v10, v8, v14
101 ; CHECK-NEXT: vmv.v.x v8, a1
102 ; CHECK-NEXT: slli a0, a0, 63
103 ; CHECK-NEXT: vmerge.vxm v8, v8, a0, v0
104 ; CHECK-NEXT: vmv1r.v v0, v10
105 ; CHECK-NEXT: vmerge.vvm v8, v12, v8, v0
107 %tmp = call <vscale x 2 x i64> @llvm.sshl.sat.nxv2i64(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y)
108 ret <vscale x 2 x i64> %tmp
111 define <vscale x 4 x i32> @vec_nxv4i32(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y) nounwind {
112 ; CHECK-LABEL: vec_nxv4i32:
114 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
115 ; CHECK-NEXT: vmsle.vi v0, v8, -1
116 ; CHECK-NEXT: lui a0, 524288
117 ; CHECK-NEXT: vsll.vv v12, v8, v10
118 ; CHECK-NEXT: addi a1, a0, -1
119 ; CHECK-NEXT: vsra.vv v14, v12, v10
120 ; CHECK-NEXT: vmsne.vv v10, v8, v14
121 ; CHECK-NEXT: vmv.v.x v8, a1
122 ; CHECK-NEXT: vmerge.vxm v8, v8, a0, v0
123 ; CHECK-NEXT: vmv1r.v v0, v10
124 ; CHECK-NEXT: vmerge.vvm v8, v12, v8, v0
126 %tmp = call <vscale x 4 x i32> @llvm.sshl.sat.nxv4i32(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y)
127 ret <vscale x 4 x i32> %tmp
130 define <vscale x 8 x i16> @vec_nxv8i16(<vscale x 8 x i16> %x, <vscale x 8 x i16> %y) nounwind {
131 ; CHECK-LABEL: vec_nxv8i16:
133 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
134 ; CHECK-NEXT: vmsle.vi v0, v8, -1
135 ; CHECK-NEXT: lui a0, 8
136 ; CHECK-NEXT: vsll.vv v12, v8, v10
137 ; CHECK-NEXT: addi a1, a0, -1
138 ; CHECK-NEXT: vsra.vv v14, v12, v10
139 ; CHECK-NEXT: vmsne.vv v10, v8, v14
140 ; CHECK-NEXT: vmv.v.x v8, a1
141 ; CHECK-NEXT: vmerge.vxm v8, v8, a0, v0
142 ; CHECK-NEXT: vmv1r.v v0, v10
143 ; CHECK-NEXT: vmerge.vvm v8, v12, v8, v0
145 %tmp = call <vscale x 8 x i16> @llvm.sshl.sat.nxv8i16(<vscale x 8 x i16> %x, <vscale x 8 x i16> %y)
146 ret <vscale x 8 x i16> %tmp
149 define <vscale x 16 x i8> @vec_nxv16i8(<vscale x 16 x i8> %x, <vscale x 16 x i8> %y) nounwind {
150 ; CHECK-LABEL: vec_nxv16i8:
152 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
153 ; CHECK-NEXT: vmsle.vi v0, v8, -1
154 ; CHECK-NEXT: li a0, 127
155 ; CHECK-NEXT: vsll.vv v12, v8, v10
156 ; CHECK-NEXT: vsra.vv v14, v12, v10
157 ; CHECK-NEXT: vmsne.vv v10, v8, v14
158 ; CHECK-NEXT: vmv.v.x v8, a0
159 ; CHECK-NEXT: li a0, 128
160 ; CHECK-NEXT: vmerge.vxm v8, v8, a0, v0
161 ; CHECK-NEXT: vmv1r.v v0, v10
162 ; CHECK-NEXT: vmerge.vvm v8, v12, v8, v0
164 %tmp = call <vscale x 16 x i8> @llvm.sshl.sat.nxv16i8(<vscale x 16 x i8> %x, <vscale x 16 x i8> %y)
165 ret <vscale x 16 x i8> %tmp