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