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: bif v0.16b, v1.16b, v2.16b
67 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
68 %mx = and <4 x i32> %mask, %x
69 %my = and <4 x i32> %notmask, <i32 42, i32 42, i32 42, i32 42>
70 %r = or <4 x i32> %mx, %my
74 define <4 x i32> @in_constant_varx_42(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
75 ; CHECK-LABEL: in_constant_varx_42:
77 ; CHECK-NEXT: movi v1.4s, #42
78 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
80 %n0 = xor <4 x i32> %x, <i32 42, i32 42, i32 42, i32 42> ; %x
81 %n1 = and <4 x i32> %n0, %mask
82 %r = xor <4 x i32> %n1, <i32 42, i32 42, i32 42, i32 42>
86 ; This is not a canonical form. Testing for completeness only.
87 define <4 x i32> @out_constant_varx_42_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
88 ; CHECK-LABEL: out_constant_varx_42_invmask:
90 ; CHECK-NEXT: movi v1.4s, #42
91 ; CHECK-NEXT: bit v0.16b, v1.16b, v2.16b
93 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
94 %mx = and <4 x i32> %notmask, %x
95 %my = and <4 x i32> %mask, <i32 42, i32 42, i32 42, i32 42>
96 %r = or <4 x i32> %mx, %my
100 ; This is not a canonical form. Testing for completeness only.
101 define <4 x i32> @in_constant_varx_42_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
102 ; CHECK-LABEL: in_constant_varx_42_invmask:
104 ; CHECK-NEXT: movi v1.4s, #42
105 ; CHECK-NEXT: bit v0.16b, v1.16b, v2.16b
107 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
108 %n0 = xor <4 x i32> %x, <i32 42, i32 42, i32 42, i32 42> ; %x
109 %n1 = and <4 x i32> %n0, %notmask
110 %r = xor <4 x i32> %n1, <i32 42, i32 42, i32 42, i32 42>
114 define <4 x i32> @out_constant_mone_vary(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
115 ; CHECK-LABEL: out_constant_mone_vary:
117 ; CHECK-NEXT: orr v0.16b, v1.16b, v2.16b
119 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
120 %mx = and <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
121 %my = and <4 x i32> %notmask, %y
122 %r = or <4 x i32> %mx, %my
126 define <4 x i32> @in_constant_mone_vary(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
127 ; CHECK-LABEL: in_constant_mone_vary:
129 ; CHECK-NEXT: orr v0.16b, v2.16b, v1.16b
131 %n0 = xor <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, %y ; %x
132 %n1 = and <4 x i32> %n0, %mask
133 %r = xor <4 x i32> %n1, %y
137 ; This is not a canonical form. Testing for completeness only.
138 define <4 x i32> @out_constant_mone_vary_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
139 ; CHECK-LABEL: out_constant_mone_vary_invmask:
141 ; CHECK-NEXT: and v0.16b, v2.16b, v1.16b
142 ; CHECK-NEXT: orn v0.16b, v0.16b, v2.16b
144 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
145 %mx = and <4 x i32> %notmask, <i32 -1, i32 -1, i32 -1, i32 -1>
146 %my = and <4 x i32> %mask, %y
147 %r = or <4 x i32> %mx, %my
151 ; This is not a canonical form. Testing for completeness only.
152 define <4 x i32> @in_constant_mone_vary_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
153 ; CHECK-LABEL: in_constant_mone_vary_invmask:
155 ; CHECK-NEXT: orn v0.16b, v1.16b, v2.16b
157 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
158 %n0 = xor <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, %y ; %x
159 %n1 = and <4 x i32> %n0, %notmask
160 %r = xor <4 x i32> %n1, %y
164 define <4 x i32> @out_constant_42_vary(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
165 ; CHECK-LABEL: out_constant_42_vary:
167 ; CHECK-NEXT: movi v0.4s, #42
168 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
170 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
171 %mx = and <4 x i32> %mask, <i32 42, i32 42, i32 42, i32 42>
172 %my = and <4 x i32> %notmask, %y
173 %r = or <4 x i32> %mx, %my
177 define <4 x i32> @in_constant_42_vary(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
178 ; CHECK-LABEL: in_constant_42_vary:
180 ; CHECK-NEXT: movi v0.4s, #42
181 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
183 %n0 = xor <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %y ; %x
184 %n1 = and <4 x i32> %n0, %mask
185 %r = xor <4 x i32> %n1, %y
189 ; This is not a canonical form. Testing for completeness only.
190 define <4 x i32> @out_constant_42_vary_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
191 ; CHECK-LABEL: out_constant_42_vary_invmask:
193 ; CHECK-NEXT: movi v0.4s, #42
194 ; CHECK-NEXT: bit v0.16b, v1.16b, v2.16b
196 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
197 %mx = and <4 x i32> %notmask, <i32 42, i32 42, i32 42, i32 42>
198 %my = and <4 x i32> %mask, %y
199 %r = or <4 x i32> %mx, %my
203 ; This is not a canonical form. Testing for completeness only.
204 define <4 x i32> @in_constant_42_vary_invmask(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) {
205 ; CHECK-LABEL: in_constant_42_vary_invmask:
207 ; CHECK-NEXT: movi v0.4s, #42
208 ; CHECK-NEXT: bit v0.16b, v1.16b, v2.16b
210 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
211 %n0 = xor <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %y ; %x
212 %n1 = and <4 x i32> %n0, %notmask
213 %r = xor <4 x i32> %n1, %y