1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le-unknown-unknown | FileCheck %s
4 ; First, check the generic pattern for any 2 vector constants. Then, check special cases where
5 ; the constants are all off-by-one. Finally, check the extra special cases where the constants
7 ; Each minimal select test is repeated with a more typical pattern that includes a compare to
8 ; generate the condition value.
10 define <4 x i32> @sel_C1_or_C2_vec(<4 x i1> %cond) {
11 ; CHECK-LABEL: sel_C1_or_C2_vec:
13 ; CHECK-NEXT: vspltisw 3, -16
14 ; CHECK-NEXT: vspltisw 4, 15
15 ; CHECK-NEXT: addis 3, 2, .LCPI0_0@toc@ha
16 ; CHECK-NEXT: addis 4, 2, .LCPI0_1@toc@ha
17 ; CHECK-NEXT: addi 3, 3, .LCPI0_0@toc@l
18 ; CHECK-NEXT: addi 4, 4, .LCPI0_1@toc@l
19 ; CHECK-NEXT: vsubuwm 3, 4, 3
20 ; CHECK-NEXT: lvx 4, 0, 4
21 ; CHECK-NEXT: vslw 2, 2, 3
22 ; CHECK-NEXT: vsraw 2, 2, 3
23 ; CHECK-NEXT: lvx 3, 0, 3
24 ; CHECK-NEXT: xxsel 34, 36, 35, 34
26 %add = select <4 x i1> %cond, <4 x i32> <i32 3000, i32 1, i32 -1, i32 0>, <4 x i32> <i32 42, i32 0, i32 -2, i32 -1>
30 define <4 x i32> @cmp_sel_C1_or_C2_vec(<4 x i32> %x, <4 x i32> %y) {
31 ; CHECK-LABEL: cmp_sel_C1_or_C2_vec:
33 ; CHECK-NEXT: vcmpequw 2, 2, 3
34 ; CHECK-NEXT: addis 3, 2, .LCPI1_0@toc@ha
35 ; CHECK-NEXT: addis 4, 2, .LCPI1_1@toc@ha
36 ; CHECK-NEXT: addi 3, 3, .LCPI1_0@toc@l
37 ; CHECK-NEXT: addi 4, 4, .LCPI1_1@toc@l
38 ; CHECK-NEXT: lvx 3, 0, 3
39 ; CHECK-NEXT: lvx 4, 0, 4
40 ; CHECK-NEXT: xxsel 34, 36, 35, 34
42 %cond = icmp eq <4 x i32> %x, %y
43 %add = select <4 x i1> %cond, <4 x i32> <i32 3000, i32 1, i32 -1, i32 0>, <4 x i32> <i32 42, i32 0, i32 -2, i32 -1>
47 define <4 x i32> @sel_Cplus1_or_C_vec(<4 x i1> %cond) {
48 ; CHECK-LABEL: sel_Cplus1_or_C_vec:
50 ; CHECK-NEXT: vspltisw 3, 1
51 ; CHECK-NEXT: addis 3, 2, .LCPI2_0@toc@ha
52 ; CHECK-NEXT: addi 3, 3, .LCPI2_0@toc@l
53 ; CHECK-NEXT: xxland 34, 34, 35
54 ; CHECK-NEXT: lvx 3, 0, 3
55 ; CHECK-NEXT: vadduwm 2, 2, 3
57 %add = select <4 x i1> %cond, <4 x i32> <i32 43, i32 1, i32 -1, i32 0>, <4 x i32> <i32 42, i32 0, i32 -2, i32 -1>
61 define <4 x i32> @cmp_sel_Cplus1_or_C_vec(<4 x i32> %x, <4 x i32> %y) {
62 ; CHECK-LABEL: cmp_sel_Cplus1_or_C_vec:
64 ; CHECK-NEXT: vcmpequw 2, 2, 3
65 ; CHECK-NEXT: addis 3, 2, .LCPI3_0@toc@ha
66 ; CHECK-NEXT: addi 3, 3, .LCPI3_0@toc@l
67 ; CHECK-NEXT: lvx 3, 0, 3
68 ; CHECK-NEXT: vsubuwm 2, 3, 2
70 %cond = icmp eq <4 x i32> %x, %y
71 %add = select <4 x i1> %cond, <4 x i32> <i32 43, i32 1, i32 -1, i32 0>, <4 x i32> <i32 42, i32 0, i32 -2, i32 -1>
75 define <4 x i32> @sel_Cminus1_or_C_vec(<4 x i1> %cond) {
76 ; CHECK-LABEL: sel_Cminus1_or_C_vec:
78 ; CHECK-NEXT: vspltisw 3, -16
79 ; CHECK-NEXT: vspltisw 4, 15
80 ; CHECK-NEXT: addis 3, 2, .LCPI4_0@toc@ha
81 ; CHECK-NEXT: addi 3, 3, .LCPI4_0@toc@l
82 ; CHECK-NEXT: vsubuwm 3, 4, 3
83 ; CHECK-NEXT: vslw 2, 2, 3
84 ; CHECK-NEXT: vsraw 2, 2, 3
85 ; CHECK-NEXT: lvx 3, 0, 3
86 ; CHECK-NEXT: vadduwm 2, 2, 3
88 %add = select <4 x i1> %cond, <4 x i32> <i32 43, i32 1, i32 -1, i32 0>, <4 x i32> <i32 44, i32 2, i32 0, i32 1>
92 define <4 x i32> @cmp_sel_Cminus1_or_C_vec(<4 x i32> %x, <4 x i32> %y) {
93 ; CHECK-LABEL: cmp_sel_Cminus1_or_C_vec:
95 ; CHECK-NEXT: vcmpequw 2, 2, 3
96 ; CHECK-NEXT: addis 3, 2, .LCPI5_0@toc@ha
97 ; CHECK-NEXT: addi 3, 3, .LCPI5_0@toc@l
98 ; CHECK-NEXT: lvx 3, 0, 3
99 ; CHECK-NEXT: vadduwm 2, 2, 3
101 %cond = icmp eq <4 x i32> %x, %y
102 %add = select <4 x i1> %cond, <4 x i32> <i32 43, i32 1, i32 -1, i32 0>, <4 x i32> <i32 44, i32 2, i32 0, i32 1>
106 define <4 x i32> @sel_minus1_or_0_vec(<4 x i1> %cond) {
107 ; CHECK-LABEL: sel_minus1_or_0_vec:
109 ; CHECK-NEXT: vspltisw 3, -16
110 ; CHECK-NEXT: vspltisw 4, 15
111 ; CHECK-NEXT: vsubuwm 3, 4, 3
112 ; CHECK-NEXT: vslw 2, 2, 3
113 ; CHECK-NEXT: vsraw 2, 2, 3
115 %add = select <4 x i1> %cond, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
119 define <4 x i32> @cmp_sel_minus1_or_0_vec(<4 x i32> %x, <4 x i32> %y) {
120 ; CHECK-LABEL: cmp_sel_minus1_or_0_vec:
122 ; CHECK-NEXT: vcmpequw 2, 2, 3
124 %cond = icmp eq <4 x i32> %x, %y
125 %add = select <4 x i1> %cond, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
129 define <4 x i32> @sel_0_or_minus1_vec(<4 x i1> %cond) {
130 ; CHECK-LABEL: sel_0_or_minus1_vec:
132 ; CHECK-NEXT: vspltisw 3, 1
133 ; CHECK-NEXT: vspltisb 4, -1
134 ; CHECK-NEXT: xxland 34, 34, 35
135 ; CHECK-NEXT: vadduwm 2, 2, 4
137 %add = select <4 x i1> %cond, <4 x i32> <i32 0, i32 0, i32 0, i32 0>, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
141 define <4 x i32> @cmp_sel_0_or_minus1_vec(<4 x i32> %x, <4 x i32> %y) {
142 ; CHECK-LABEL: cmp_sel_0_or_minus1_vec:
144 ; CHECK-NEXT: vcmpequw 2, 2, 3
145 ; CHECK-NEXT: xxlnor 34, 34, 34
147 %cond = icmp eq <4 x i32> %x, %y
148 %add = select <4 x i1> %cond, <4 x i32> <i32 0, i32 0, i32 0, i32 0>, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
152 define <4 x i32> @sel_1_or_0_vec(<4 x i1> %cond) {
153 ; CHECK-LABEL: sel_1_or_0_vec:
155 ; CHECK-NEXT: vspltisw 3, 1
156 ; CHECK-NEXT: xxland 34, 34, 35
158 %add = select <4 x i1> %cond, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
162 define <4 x i32> @cmp_sel_1_or_0_vec(<4 x i32> %x, <4 x i32> %y) {
163 ; CHECK-LABEL: cmp_sel_1_or_0_vec:
165 ; CHECK-NEXT: vcmpequw 2, 2, 3
166 ; CHECK-NEXT: vspltisw 3, 1
167 ; CHECK-NEXT: xxland 34, 34, 35
169 %cond = icmp eq <4 x i32> %x, %y
170 %add = select <4 x i1> %cond, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
174 define <4 x i32> @sel_0_or_1_vec(<4 x i1> %cond) {
175 ; CHECK-LABEL: sel_0_or_1_vec:
177 ; CHECK-NEXT: vspltisw 3, 1
178 ; CHECK-NEXT: xxlandc 34, 35, 34
180 %add = select <4 x i1> %cond, <4 x i32> <i32 0, i32 0, i32 0, i32 0>, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
184 define <4 x i32> @cmp_sel_0_or_1_vec(<4 x i32> %x, <4 x i32> %y) {
185 ; CHECK-LABEL: cmp_sel_0_or_1_vec:
187 ; CHECK-NEXT: vcmpequw 2, 2, 3
188 ; CHECK-NEXT: vspltisw 3, 1
189 ; CHECK-NEXT: xxlnor 0, 34, 34
190 ; CHECK-NEXT: xxland 34, 0, 35
192 %cond = icmp eq <4 x i32> %x, %y
193 %add = select <4 x i1> %cond, <4 x i32> <i32 0, i32 0, i32 0, i32 0>, <4 x i32> <i32 1, i32 1, i32 1, i32 1>