1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-- | 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: adrp x8, .LCPI0_0
14 ; CHECK-NEXT: adrp x9, .LCPI0_1
15 ; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI0_0]
16 ; CHECK-NEXT: ldr q2, [x9, :lo12:.LCPI0_1]
17 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
18 ; CHECK-NEXT: shl v0.4s, v0.4s, #31
19 ; CHECK-NEXT: sshr v0.4s, v0.4s, #31
20 ; CHECK-NEXT: bsl v0.16b, v2.16b, v1.16b
22 %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>
26 define <4 x i32> @cmp_sel_C1_or_C2_vec(<4 x i32> %x, <4 x i32> %y) {
27 ; CHECK-LABEL: cmp_sel_C1_or_C2_vec:
29 ; CHECK-NEXT: adrp x8, .LCPI1_0
30 ; CHECK-NEXT: adrp x9, .LCPI1_1
31 ; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI1_0]
32 ; CHECK-NEXT: ldr q3, [x9, :lo12:.LCPI1_1]
33 ; CHECK-NEXT: cmeq v0.4s, v0.4s, v1.4s
34 ; CHECK-NEXT: bsl v0.16b, v3.16b, v2.16b
36 %cond = icmp eq <4 x i32> %x, %y
37 %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>
41 define <4 x i32> @sel_Cplus1_or_C_vec(<4 x i1> %cond) {
42 ; CHECK-LABEL: sel_Cplus1_or_C_vec:
44 ; CHECK-NEXT: adrp x8, .LCPI2_0
45 ; CHECK-NEXT: adrp x9, .LCPI2_1
46 ; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI2_0]
47 ; CHECK-NEXT: ldr q2, [x9, :lo12:.LCPI2_1]
48 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
49 ; CHECK-NEXT: shl v0.4s, v0.4s, #31
50 ; CHECK-NEXT: sshr v0.4s, v0.4s, #31
51 ; CHECK-NEXT: bsl v0.16b, v2.16b, v1.16b
53 %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>
57 define <4 x i32> @cmp_sel_Cplus1_or_C_vec(<4 x i32> %x, <4 x i32> %y) {
58 ; CHECK-LABEL: cmp_sel_Cplus1_or_C_vec:
60 ; CHECK-NEXT: adrp x8, .LCPI3_0
61 ; CHECK-NEXT: adrp x9, .LCPI3_1
62 ; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI3_0]
63 ; CHECK-NEXT: ldr q3, [x9, :lo12:.LCPI3_1]
64 ; CHECK-NEXT: cmeq v0.4s, v0.4s, v1.4s
65 ; CHECK-NEXT: bsl v0.16b, v3.16b, v2.16b
67 %cond = icmp eq <4 x i32> %x, %y
68 %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>
72 define <4 x i32> @sel_Cminus1_or_C_vec(<4 x i1> %cond) {
73 ; CHECK-LABEL: sel_Cminus1_or_C_vec:
75 ; CHECK-NEXT: adrp x8, .LCPI4_0
76 ; CHECK-NEXT: adrp x9, .LCPI4_1
77 ; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI4_0]
78 ; CHECK-NEXT: ldr q2, [x9, :lo12:.LCPI4_1]
79 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
80 ; CHECK-NEXT: shl v0.4s, v0.4s, #31
81 ; CHECK-NEXT: sshr v0.4s, v0.4s, #31
82 ; CHECK-NEXT: bsl v0.16b, v2.16b, v1.16b
84 %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>
88 define <4 x i32> @cmp_sel_Cminus1_or_C_vec(<4 x i32> %x, <4 x i32> %y) {
89 ; CHECK-LABEL: cmp_sel_Cminus1_or_C_vec:
91 ; CHECK-NEXT: adrp x8, .LCPI5_0
92 ; CHECK-NEXT: adrp x9, .LCPI5_1
93 ; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI5_0]
94 ; CHECK-NEXT: ldr q3, [x9, :lo12:.LCPI5_1]
95 ; CHECK-NEXT: cmeq v0.4s, v0.4s, v1.4s
96 ; CHECK-NEXT: bsl v0.16b, v3.16b, v2.16b
98 %cond = icmp eq <4 x i32> %x, %y
99 %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>
103 define <4 x i32> @sel_minus1_or_0_vec(<4 x i1> %cond) {
104 ; CHECK-LABEL: sel_minus1_or_0_vec:
106 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
107 ; CHECK-NEXT: shl v0.4s, v0.4s, #31
108 ; CHECK-NEXT: sshr v0.4s, v0.4s, #31
110 %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>
114 define <4 x i32> @cmp_sel_minus1_or_0_vec(<4 x i32> %x, <4 x i32> %y) {
115 ; CHECK-LABEL: cmp_sel_minus1_or_0_vec:
117 ; CHECK-NEXT: cmeq v0.4s, v0.4s, v1.4s
119 %cond = icmp eq <4 x i32> %x, %y
120 %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>
124 define <4 x i32> @sel_0_or_minus1_vec(<4 x i1> %cond) {
125 ; CHECK-LABEL: sel_0_or_minus1_vec:
127 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
128 ; CHECK-NEXT: shl v0.4s, v0.4s, #31
129 ; CHECK-NEXT: cmge v0.4s, v0.4s, #0
131 %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>
135 define <4 x i32> @cmp_sel_0_or_minus1_vec(<4 x i32> %x, <4 x i32> %y) {
136 ; CHECK-LABEL: cmp_sel_0_or_minus1_vec:
138 ; CHECK-NEXT: cmeq v0.4s, v0.4s, v1.4s
139 ; CHECK-NEXT: mvn v0.16b, v0.16b
141 %cond = icmp eq <4 x i32> %x, %y
142 %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>
146 define <4 x i32> @sel_1_or_0_vec(<4 x i1> %cond) {
147 ; CHECK-LABEL: sel_1_or_0_vec:
149 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
150 ; CHECK-NEXT: shl v0.4s, v0.4s, #31
151 ; CHECK-NEXT: sshr v0.4s, v0.4s, #31
152 ; CHECK-NEXT: movi v1.4s, #1
153 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
155 %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>
159 define <4 x i32> @cmp_sel_1_or_0_vec(<4 x i32> %x, <4 x i32> %y) {
160 ; CHECK-LABEL: cmp_sel_1_or_0_vec:
162 ; CHECK-NEXT: cmeq v0.4s, v0.4s, v1.4s
163 ; CHECK-NEXT: movi v1.4s, #1
164 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
166 %cond = icmp eq <4 x i32> %x, %y
167 %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>
171 define <4 x i32> @sel_0_or_1_vec(<4 x i1> %cond) {
172 ; CHECK-LABEL: sel_0_or_1_vec:
174 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
175 ; CHECK-NEXT: shl v0.4s, v0.4s, #31
176 ; CHECK-NEXT: cmge v0.4s, v0.4s, #0
177 ; CHECK-NEXT: movi v1.4s, #1
178 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
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: cmeq v0.4s, v0.4s, v1.4s
188 ; CHECK-NEXT: movi v1.4s, #1
189 ; CHECK-NEXT: bic v0.16b, v1.16b, v0.16b
191 %cond = icmp eq <4 x i32> %x, %y
192 %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>