1 ; Test vector sign extensions.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
5 ; Test a v16i1->v16i8 extension.
6 define <16 x i8> @f1(<16 x i8> %val) {
8 ; CHECK: veslb [[REG:%v[0-9]+]], %v24, 7
9 ; CHECK: vesrab %v24, [[REG]], 7
11 %trunc = trunc <16 x i8> %val to <16 x i1>
12 %ret = sext <16 x i1> %trunc to <16 x i8>
16 ; Test a v8i1->v8i16 extension.
17 define <8 x i16> @f2(<8 x i16> %val) {
19 ; CHECK: veslh [[REG:%v[0-9]+]], %v24, 15
20 ; CHECK: vesrah %v24, [[REG]], 15
22 %trunc = trunc <8 x i16> %val to <8 x i1>
23 %ret = sext <8 x i1> %trunc to <8 x i16>
27 ; Test a v8i8->v8i16 extension.
28 define <8 x i16> @f3(<8 x i16> %val) {
30 ; CHECK: veslh [[REG:%v[0-9]+]], %v24, 8
31 ; CHECK: vesrah %v24, [[REG]], 8
33 %trunc = trunc <8 x i16> %val to <8 x i8>
34 %ret = sext <8 x i8> %trunc to <8 x i16>
38 ; Test a v4i1->v4i32 extension.
39 define <4 x i32> @f4(<4 x i32> %val) {
41 ; CHECK: veslf [[REG:%v[0-9]+]], %v24, 31
42 ; CHECK: vesraf %v24, [[REG]], 31
44 %trunc = trunc <4 x i32> %val to <4 x i1>
45 %ret = sext <4 x i1> %trunc to <4 x i32>
49 ; Test a v4i8->v4i32 extension.
50 define <4 x i32> @f5(<4 x i32> %val) {
52 ; CHECK: veslf [[REG:%v[0-9]+]], %v24, 24
53 ; CHECK: vesraf %v24, [[REG]], 24
55 %trunc = trunc <4 x i32> %val to <4 x i8>
56 %ret = sext <4 x i8> %trunc to <4 x i32>
60 ; Test a v4i16->v4i32 extension.
61 define <4 x i32> @f6(<4 x i32> %val) {
63 ; CHECK: veslf [[REG:%v[0-9]+]], %v24, 16
64 ; CHECK: vesraf %v24, [[REG]], 16
66 %trunc = trunc <4 x i32> %val to <4 x i16>
67 %ret = sext <4 x i16> %trunc to <4 x i32>
71 ; Test a v2i1->v2i64 extension.
72 define <2 x i64> @f7(<2 x i64> %val) {
74 ; CHECK: veslg [[REG:%v[0-9]+]], %v24, 63
75 ; CHECK: vesrag %v24, [[REG]], 63
77 %trunc = trunc <2 x i64> %val to <2 x i1>
78 %ret = sext <2 x i1> %trunc to <2 x i64>
82 ; Test a v2i8->v2i64 extension.
83 define <2 x i64> @f8(<2 x i64> %val) {
85 ; CHECK: vsegb %v24, %v24
87 %trunc = trunc <2 x i64> %val to <2 x i8>
88 %ret = sext <2 x i8> %trunc to <2 x i64>
92 ; Test a v2i16->v2i64 extension.
93 define <2 x i64> @f9(<2 x i64> %val) {
95 ; CHECK: vsegh %v24, %v24
97 %trunc = trunc <2 x i64> %val to <2 x i16>
98 %ret = sext <2 x i16> %trunc to <2 x i64>
102 ; Test a v2i32->v2i64 extension.
103 define <2 x i64> @f10(<2 x i64> %val) {
105 ; CHECK: vsegf %v24, %v24
107 %trunc = trunc <2 x i64> %val to <2 x i32>
108 %ret = sext <2 x i32> %trunc to <2 x i64>
112 ; Test an alternative v2i8->v2i64 extension.
113 define <2 x i64> @f11(<2 x i64> %val) {
115 ; CHECK: vsegb %v24, %v24
117 %shl = shl <2 x i64> %val, <i64 56, i64 56>
118 %ret = ashr <2 x i64> %shl, <i64 56, i64 56>
122 ; Test an alternative v2i16->v2i64 extension.
123 define <2 x i64> @f12(<2 x i64> %val) {
125 ; CHECK: vsegh %v24, %v24
127 %shl = shl <2 x i64> %val, <i64 48, i64 48>
128 %ret = ashr <2 x i64> %shl, <i64 48, i64 48>
132 ; Test an alternative v2i32->v2i64 extension.
133 define <2 x i64> @f13(<2 x i64> %val) {
135 ; CHECK: vsegf %v24, %v24
137 %shl = shl <2 x i64> %val, <i64 32, i64 32>
138 %ret = ashr <2 x i64> %shl, <i64 32, i64 32>
142 ; Test an extraction-based v2i8->v2i64 extension.
143 define <2 x i64> @f14(<16 x i8> %val) {
145 ; CHECK: vsegb %v24, %v24
147 %elt0 = extractelement <16 x i8> %val, i32 7
148 %elt1 = extractelement <16 x i8> %val, i32 15
149 %ext0 = sext i8 %elt0 to i64
150 %ext1 = sext i8 %elt1 to i64
151 %vec0 = insertelement <2 x i64> undef, i64 %ext0, i32 0
152 %vec1 = insertelement <2 x i64> %vec0, i64 %ext1, i32 1
156 ; Test an extraction-based v2i16->v2i64 extension.
157 define <2 x i64> @f15(<16 x i16> %val) {
159 ; CHECK: vsegh %v24, %v24
161 %elt0 = extractelement <16 x i16> %val, i32 3
162 %elt1 = extractelement <16 x i16> %val, i32 7
163 %ext0 = sext i16 %elt0 to i64
164 %ext1 = sext i16 %elt1 to i64
165 %vec0 = insertelement <2 x i64> undef, i64 %ext0, i32 0
166 %vec1 = insertelement <2 x i64> %vec0, i64 %ext1, i32 1
170 ; Test an extraction-based v2i32->v2i64 extension.
171 define <2 x i64> @f16(<16 x i32> %val) {
173 ; CHECK: vsegf %v24, %v24
175 %elt0 = extractelement <16 x i32> %val, i32 1
176 %elt1 = extractelement <16 x i32> %val, i32 3
177 %ext0 = sext i32 %elt0 to i64
178 %ext1 = sext i32 %elt1 to i64
179 %vec0 = insertelement <2 x i64> undef, i64 %ext0, i32 0
180 %vec1 = insertelement <2 x i64> %vec0, i64 %ext1, i32 1