3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
6 define <8 x i16> @f1(<8 x i16> %val) {
8 ; CHECK: vlph %v24, %v24
10 %cmp = icmp slt <8 x i16> %val, zeroinitializer
11 %neg = sub <8 x i16> zeroinitializer, %val
12 %ret = select <8 x i1> %cmp, <8 x i16> %neg, <8 x i16> %val
17 define <8 x i16> @f2(<8 x i16> %val) {
19 ; CHECK: vlph %v24, %v24
21 %cmp = icmp sle <8 x i16> %val, zeroinitializer
22 %neg = sub <8 x i16> zeroinitializer, %val
23 %ret = select <8 x i1> %cmp, <8 x i16> %neg, <8 x i16> %val
28 define <8 x i16> @f3(<8 x i16> %val) {
30 ; CHECK: vlph %v24, %v24
32 %cmp = icmp sgt <8 x i16> %val, zeroinitializer
33 %neg = sub <8 x i16> zeroinitializer, %val
34 %ret = select <8 x i1> %cmp, <8 x i16> %val, <8 x i16> %neg
39 define <8 x i16> @f4(<8 x i16> %val) {
41 ; CHECK: vlph %v24, %v24
43 %cmp = icmp sge <8 x i16> %val, zeroinitializer
44 %neg = sub <8 x i16> zeroinitializer, %val
45 %ret = select <8 x i1> %cmp, <8 x i16> %val, <8 x i16> %neg
49 ; Test that negative absolute uses VLPH too. There is no vector equivalent
51 define <8 x i16> @f5(<8 x i16> %val) {
53 ; CHECK: vlph [[REG:%v[0-9]+]], %v24
54 ; CHECK: vlch %v24, [[REG]]
56 %cmp = icmp slt <8 x i16> %val, zeroinitializer
57 %neg = sub <8 x i16> zeroinitializer, %val
58 %abs = select <8 x i1> %cmp, <8 x i16> %neg, <8 x i16> %val
59 %ret = sub <8 x i16> zeroinitializer, %abs
63 ; Try another form of negative absolute (slt version).
64 define <8 x i16> @f6(<8 x i16> %val) {
66 ; CHECK: vlph [[REG:%v[0-9]+]], %v24
67 ; CHECK: vlch %v24, [[REG]]
69 %cmp = icmp slt <8 x i16> %val, zeroinitializer
70 %neg = sub <8 x i16> zeroinitializer, %val
71 %ret = select <8 x i1> %cmp, <8 x i16> %val, <8 x i16> %neg
76 define <8 x i16> @f7(<8 x i16> %val) {
78 ; CHECK: vlph [[REG:%v[0-9]+]], %v24
79 ; CHECK: vlch %v24, [[REG]]
81 %cmp = icmp sle <8 x i16> %val, zeroinitializer
82 %neg = sub <8 x i16> zeroinitializer, %val
83 %ret = select <8 x i1> %cmp, <8 x i16> %val, <8 x i16> %neg
88 define <8 x i16> @f8(<8 x i16> %val) {
90 ; CHECK: vlph [[REG:%v[0-9]+]], %v24
91 ; CHECK: vlch %v24, [[REG]]
93 %cmp = icmp sgt <8 x i16> %val, zeroinitializer
94 %neg = sub <8 x i16> zeroinitializer, %val
95 %ret = select <8 x i1> %cmp, <8 x i16> %neg, <8 x i16> %val
100 define <8 x i16> @f9(<8 x i16> %val) {
102 ; CHECK: vlph [[REG:%v[0-9]+]], %v24
103 ; CHECK: vlch %v24, [[REG]]
105 %cmp = icmp sge <8 x i16> %val, zeroinitializer
106 %neg = sub <8 x i16> zeroinitializer, %val
107 %ret = select <8 x i1> %cmp, <8 x i16> %neg, <8 x i16> %val
111 ; Test with an SRA-based boolean vector.
112 define <8 x i16> @f10(<8 x i16> %val) {
114 ; CHECK: vlph %v24, %v24
116 %shr = ashr <8 x i16> %val,
117 <i16 15, i16 15, i16 15, i16 15, i16 15, i16 15, i16 15, i16 15>
118 %neg = sub <8 x i16> zeroinitializer, %val
119 %and1 = and <8 x i16> %shr, %neg
120 %not = xor <8 x i16> %shr,
121 <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
122 %and2 = and <8 x i16> %not, %val
123 %ret = or <8 x i16> %and1, %and2
127 ; ...and again in reverse
128 define <8 x i16> @f11(<8 x i16> %val) {
130 ; CHECK: vlph [[REG:%v[0-9]+]], %v24
131 ; CHECK: vlch %v24, [[REG]]
133 %shr = ashr <8 x i16> %val,
134 <i16 15, i16 15, i16 15, i16 15, i16 15, i16 15, i16 15, i16 15>
135 %and1 = and <8 x i16> %shr, %val
136 %not = xor <8 x i16> %shr,
137 <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
138 %neg = sub <8 x i16> zeroinitializer, %val
139 %and2 = and <8 x i16> %not, %neg
140 %ret = or <8 x i16> %and1, %and2