1; Test vector (or (and X, Z), (and Y, (not Z))) patterns.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
4
5; Test v16i8.
6define <16 x i8> @f1(<16 x i8> %val1, <16 x i8> %val2, <16 x i8> %val3) {
7; CHECK-LABEL: f1:
8; CHECK: vsel %v24, %v24, %v26, %v28
9; CHECK: br %r14
10  %not = xor <16 x i8> %val3, <i8 -1, i8 -1, i8 -1, i8 -1,
11                               i8 -1, i8 -1, i8 -1, i8 -1,
12                               i8 -1, i8 -1, i8 -1, i8 -1,
13                               i8 -1, i8 -1, i8 -1, i8 -1>
14  %and1 = and <16 x i8> %val1, %val3
15  %and2 = and <16 x i8> %val2, %not
16  %ret = or <16 x i8> %and1, %and2
17  ret <16 x i8> %ret
18}
19
20; ...and again with the XOR applied to the other operand of the AND.
21define <16 x i8> @f2(<16 x i8> %val1, <16 x i8> %val2, <16 x i8> %val3) {
22; CHECK-LABEL: f2:
23; CHECK: vsel %v24, %v26, %v24, %v28
24; CHECK: br %r14
25  %not = xor <16 x i8> %val3, <i8 -1, i8 -1, i8 -1, i8 -1,
26                               i8 -1, i8 -1, i8 -1, i8 -1,
27                               i8 -1, i8 -1, i8 -1, i8 -1,
28                               i8 -1, i8 -1, i8 -1, i8 -1>
29  %and1 = and <16 x i8> %val1, %not
30  %and2 = and <16 x i8> %val2, %val3
31  %ret = or <16 x i8> %and1, %and2
32  ret <16 x i8> %ret
33}
34
35; Test v8i16.
36define <8 x i16> @f3(<8 x i16> %val1, <8 x i16> %val2, <8 x i16> %val3) {
37; CHECK-LABEL: f3:
38; CHECK: vsel %v24, %v24, %v26, %v28
39; CHECK: br %r14
40  %not = xor <8 x i16> %val3, <i16 -1, i16 -1, i16 -1, i16 -1,
41                               i16 -1, i16 -1, i16 -1, i16 -1>
42  %and1 = and <8 x i16> %val1, %val3
43  %and2 = and <8 x i16> %val2, %not
44  %ret = or <8 x i16> %and1, %and2
45  ret <8 x i16> %ret
46}
47
48; ...and again with the XOR applied to the other operand of the AND.
49define <8 x i16> @f4(<8 x i16> %val1, <8 x i16> %val2, <8 x i16> %val3) {
50; CHECK-LABEL: f4:
51; CHECK: vsel %v24, %v26, %v24, %v28
52; CHECK: br %r14
53  %not = xor <8 x i16> %val3, <i16 -1, i16 -1, i16 -1, i16 -1,
54                               i16 -1, i16 -1, i16 -1, i16 -1>
55  %and1 = and <8 x i16> %val1, %not
56  %and2 = and <8 x i16> %val2, %val3
57  %ret = or <8 x i16> %and1, %and2
58  ret <8 x i16> %ret
59}
60
61; Test v4i32.
62define <4 x i32> @f5(<4 x i32> %val1, <4 x i32> %val2, <4 x i32> %val3) {
63; CHECK-LABEL: f5:
64; CHECK: vsel %v24, %v24, %v26, %v28
65; CHECK: br %r14
66  %not = xor <4 x i32> %val3, <i32 -1, i32 -1, i32 -1, i32 -1>
67  %and1 = and <4 x i32> %val1, %val3
68  %and2 = and <4 x i32> %val2, %not
69  %ret = or <4 x i32> %and1, %and2
70  ret <4 x i32> %ret
71}
72
73; ...and again with the XOR applied to the other operand of the AND.
74define <4 x i32> @f6(<4 x i32> %val1, <4 x i32> %val2, <4 x i32> %val3) {
75; CHECK-LABEL: f6:
76; CHECK: vsel %v24, %v26, %v24, %v28
77; CHECK: br %r14
78  %not = xor <4 x i32> %val3, <i32 -1, i32 -1, i32 -1, i32 -1>
79  %and1 = and <4 x i32> %val1, %not
80  %and2 = and <4 x i32> %val2, %val3
81  %ret = or <4 x i32> %and1, %and2
82  ret <4 x i32> %ret
83}
84
85; Test v2i64.
86define <2 x i64> @f7(<2 x i64> %val1, <2 x i64> %val2, <2 x i64> %val3) {
87; CHECK-LABEL: f7:
88; CHECK: vsel %v24, %v24, %v26, %v28
89; CHECK: br %r14
90  %not = xor <2 x i64> %val3, <i64 -1, i64 -1>
91  %and1 = and <2 x i64> %val1, %val3
92  %and2 = and <2 x i64> %val2, %not
93  %ret = or <2 x i64> %and1, %and2
94  ret <2 x i64> %ret
95}
96
97; ...and again with the XOR applied to the other operand of the AND.
98define <2 x i64> @f8(<2 x i64> %val1, <2 x i64> %val2, <2 x i64> %val3) {
99; CHECK-LABEL: f8:
100; CHECK: vsel %v24, %v26, %v24, %v28
101; CHECK: br %r14
102  %not = xor <2 x i64> %val3, <i64 -1, i64 -1>
103  %and1 = and <2 x i64> %val1, %not
104  %and2 = and <2 x i64> %val2, %val3
105  %ret = or <2 x i64> %and1, %and2
106  ret <2 x i64> %ret
107}
108