1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
4 ; ============================================================================ ;
5 ; Various cases with %x and/or %y being a constant
6 ; ============================================================================ ;
8 define <4 x i32> @out_constant_varx_mone(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
9 ; CHECK-LABEL: out_constant_varx_mone:
11 ; CHECK-NEXT: and v0.16b, v2.16b, v0.16b
12 ; CHECK-NEXT: orn v0.16b, v0.16b, v2.16b
14 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
15 %mx = and <4 x i32> %mask, %x
16 %my = and <4 x i32> %notmask, <i32 -1, i32 -1, i32 -1, i32 -1>
17 %r = or <4 x i32> %mx, %my
21 define <4 x i32> @in_constant_varx_mone(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
22 ; CHECK-LABEL: in_constant_varx_mone:
24 ; CHECK-NEXT: bic v0.16b, v2.16b, v0.16b
25 ; CHECK-NEXT: mvn v0.16b, v0.16b
27 %n0 = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1> ; %x
28 %n1 = and <4 x i32> %n0, %mask
29 %r = xor <4 x i32> %n1, <i32 -1, i32 -1, i32 -1, i32 -1>
33 ; This is not a canonical form. Testing for completeness only.
34 define <4 x i32> @out_constant_varx_mone_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
35 ; CHECK-LABEL: out_constant_varx_mone_invmask:
37 ; CHECK-NEXT: orr v0.16b, v0.16b, v2.16b
39 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
40 %mx = and <4 x i32> %notmask, %x
41 %my = and <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
42 %r = or <4 x i32> %mx, %my
46 ; This is not a canonical form. Testing for completeness only.
47 define <4 x i32> @in_constant_varx_mone_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
48 ; CHECK-LABEL: in_constant_varx_mone_invmask:
50 ; CHECK-NEXT: mvn v0.16b, v0.16b
51 ; CHECK-NEXT: bic v0.16b, v0.16b, v2.16b
52 ; CHECK-NEXT: mvn v0.16b, v0.16b
54 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
55 %n0 = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1> ; %x
56 %n1 = and <4 x i32> %n0, %notmask
57 %r = xor <4 x i32> %n1, <i32 -1, i32 -1, i32 -1, i32 -1>
61 define <4 x i32> @out_constant_varx_42(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
62 ; CHECK-LABEL: out_constant_varx_42:
64 ; CHECK-NEXT: movi v1.4s, #42
65 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
66 ; CHECK-NEXT: mov v0.16b, v2.16b
68 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
69 %mx = and <4 x i32> %mask, %x
70 %my = and <4 x i32> %notmask, <i32 42, i32 42, i32 42, i32 42>
71 %r = or <4 x i32> %mx, %my
75 define <4 x i32> @in_constant_varx_42(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
76 ; CHECK-LABEL: in_constant_varx_42:
78 ; CHECK-NEXT: movi v1.4s, #42
79 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
80 ; CHECK-NEXT: mov v0.16b, v2.16b
82 %n0 = xor <4 x i32> %x, <i32 42, i32 42, i32 42, i32 42> ; %x
83 %n1 = and <4 x i32> %n0, %mask
84 %r = xor <4 x i32> %n1, <i32 42, i32 42, i32 42, i32 42>
88 ; This is not a canonical form. Testing for completeness only.
89 define <4 x i32> @out_constant_varx_42_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
90 ; CHECK-LABEL: out_constant_varx_42_invmask:
92 ; CHECK-NEXT: movi v1.4s, #42
93 ; CHECK-NEXT: bsl v2.16b, v1.16b, v0.16b
94 ; CHECK-NEXT: mov v0.16b, v2.16b
96 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
97 %mx = and <4 x i32> %notmask, %x
98 %my = and <4 x i32> %mask, <i32 42, i32 42, i32 42, i32 42>
99 %r = or <4 x i32> %mx, %my
103 ; This is not a canonical form. Testing for completeness only.
104 define <4 x i32> @in_constant_varx_42_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
105 ; CHECK-LABEL: in_constant_varx_42_invmask:
107 ; CHECK-NEXT: movi v1.4s, #42
108 ; CHECK-NEXT: bsl v2.16b, v1.16b, v0.16b
109 ; CHECK-NEXT: mov v0.16b, v2.16b
111 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
112 %n0 = xor <4 x i32> %x, <i32 42, i32 42, i32 42, i32 42> ; %x
113 %n1 = and <4 x i32> %n0, %notmask
114 %r = xor <4 x i32> %n1, <i32 42, i32 42, i32 42, i32 42>
118 define <4 x i32> @out_constant_mone_vary(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
119 ; CHECK-LABEL: out_constant_mone_vary:
121 ; CHECK-NEXT: orr v0.16b, v1.16b, v2.16b
123 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
124 %mx = and <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
125 %my = and <4 x i32> %notmask, %y
126 %r = or <4 x i32> %mx, %my
130 define <4 x i32> @in_constant_mone_vary(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
131 ; CHECK-LABEL: in_constant_mone_vary:
133 ; CHECK-NEXT: orr v0.16b, v1.16b, v2.16b
135 %n0 = xor <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, %y ; %x
136 %n1 = and <4 x i32> %n0, %mask
137 %r = xor <4 x i32> %n1, %y
141 ; This is not a canonical form. Testing for completeness only.
142 define <4 x i32> @out_constant_mone_vary_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
143 ; CHECK-LABEL: out_constant_mone_vary_invmask:
145 ; CHECK-NEXT: and v0.16b, v2.16b, v1.16b
146 ; CHECK-NEXT: orn v0.16b, v0.16b, v2.16b
148 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
149 %mx = and <4 x i32> %notmask, <i32 -1, i32 -1, i32 -1, i32 -1>
150 %my = and <4 x i32> %mask, %y
151 %r = or <4 x i32> %mx, %my
155 ; This is not a canonical form. Testing for completeness only.
156 define <4 x i32> @in_constant_mone_vary_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
157 ; CHECK-LABEL: in_constant_mone_vary_invmask:
159 ; CHECK-NEXT: and v0.16b, v1.16b, v2.16b
160 ; CHECK-NEXT: orn v0.16b, v0.16b, v2.16b
162 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
163 %n0 = xor <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, %y ; %x
164 %n1 = and <4 x i32> %n0, %notmask
165 %r = xor <4 x i32> %n1, %y
169 define <4 x i32> @out_constant_42_vary(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
170 ; CHECK-LABEL: out_constant_42_vary:
172 ; CHECK-NEXT: mov v0.16b, v2.16b
173 ; CHECK-NEXT: movi v2.4s, #42
174 ; CHECK-NEXT: bsl v0.16b, v2.16b, v1.16b
176 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
177 %mx = and <4 x i32> %mask, <i32 42, i32 42, i32 42, i32 42>
178 %my = and <4 x i32> %notmask, %y
179 %r = or <4 x i32> %mx, %my
183 define <4 x i32> @in_constant_42_vary(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
184 ; CHECK-LABEL: in_constant_42_vary:
186 ; CHECK-NEXT: mov v0.16b, v2.16b
187 ; CHECK-NEXT: movi v2.4s, #42
188 ; CHECK-NEXT: bsl v0.16b, v2.16b, v1.16b
190 %n0 = xor <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %y ; %x
191 %n1 = and <4 x i32> %n0, %mask
192 %r = xor <4 x i32> %n1, %y
196 ; This is not a canonical form. Testing for completeness only.
197 define <4 x i32> @out_constant_42_vary_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
198 ; CHECK-LABEL: out_constant_42_vary_invmask:
200 ; CHECK-NEXT: mov v0.16b, v2.16b
201 ; CHECK-NEXT: movi v2.4s, #42
202 ; CHECK-NEXT: bsl v0.16b, v1.16b, v2.16b
204 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
205 %mx = and <4 x i32> %notmask, <i32 42, i32 42, i32 42, i32 42>
206 %my = and <4 x i32> %mask, %y
207 %r = or <4 x i32> %mx, %my
211 ; This is not a canonical form. Testing for completeness only.
212 define <4 x i32> @in_constant_42_vary_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
213 ; CHECK-LABEL: in_constant_42_vary_invmask:
215 ; CHECK-NEXT: mov v0.16b, v2.16b
216 ; CHECK-NEXT: movi v2.4s, #42
217 ; CHECK-NEXT: bsl v0.16b, v1.16b, v2.16b
219 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
220 %n0 = xor <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %y ; %x
221 %n1 = and <4 x i32> %n0, %notmask
222 %r = xor <4 x i32> %n1, %y