1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,CHECK-SD
3 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu -global-isel -global-isel-abort=2 < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
5 ; CHECK-GI: warning: Instruction selection used fallback path for test_bit_sink_operand
7 ; BIT Bitwise Insert if True
11 define <1 x i8> @test_bit_v1i8(<1 x i8> %A, <1 x i8> %B, <1 x i8> %C) {
12 ; CHECK-SD-LABEL: test_bit_v1i8:
14 ; CHECK-SD-NEXT: bit v0.8b, v1.8b, v2.8b
17 ; CHECK-GI-LABEL: test_bit_v1i8:
19 ; CHECK-GI-NEXT: fmov x8, d0
20 ; CHECK-GI-NEXT: fmov x9, d1
21 ; CHECK-GI-NEXT: fmov x10, d2
22 ; CHECK-GI-NEXT: and w9, w10, w9
23 ; CHECK-GI-NEXT: bic w8, w8, w10
24 ; CHECK-GI-NEXT: orr w8, w9, w8
25 ; CHECK-GI-NEXT: fmov s0, w8
27 %and = and <1 x i8> %C, %B
28 %neg = xor <1 x i8> %C, <i8 -1>
29 %and1 = and <1 x i8> %neg, %A
30 %or = or <1 x i8> %and, %and1
34 ; 16-bit vectors tests
36 define <1 x i16> @test_bit_v1i16(<1 x i16> %A, <1 x i16> %B, <1 x i16> %C) {
37 ; CHECK-SD-LABEL: test_bit_v1i16:
39 ; CHECK-SD-NEXT: bit v0.8b, v1.8b, v2.8b
42 ; CHECK-GI-LABEL: test_bit_v1i16:
44 ; CHECK-GI-NEXT: fmov x8, d0
45 ; CHECK-GI-NEXT: fmov x9, d1
46 ; CHECK-GI-NEXT: fmov x10, d2
47 ; CHECK-GI-NEXT: and w9, w10, w9
48 ; CHECK-GI-NEXT: bic w8, w8, w10
49 ; CHECK-GI-NEXT: orr w8, w9, w8
50 ; CHECK-GI-NEXT: fmov s0, w8
52 %and = and <1 x i16> %C, %B
53 %neg = xor <1 x i16> %C, <i16 -1>
54 %and1 = and <1 x i16> %neg, %A
55 %or = or <1 x i16> %and, %and1
59 ; 32-bit vectors tests
61 define <1 x i32> @test_bit_v1i32(<1 x i32> %A, <1 x i32> %B, <1 x i32> %C) {
62 ; CHECK-SD-LABEL: test_bit_v1i32:
64 ; CHECK-SD-NEXT: bit v0.8b, v1.8b, v2.8b
67 ; CHECK-GI-LABEL: test_bit_v1i32:
69 ; CHECK-GI-NEXT: fmov x8, d0
70 ; CHECK-GI-NEXT: fmov x9, d1
71 ; CHECK-GI-NEXT: fmov x10, d2
72 ; CHECK-GI-NEXT: and w9, w10, w9
73 ; CHECK-GI-NEXT: bic w8, w8, w10
74 ; CHECK-GI-NEXT: orr w8, w9, w8
75 ; CHECK-GI-NEXT: fmov s0, w8
76 ; CHECK-GI-NEXT: mov v0.s[1], w8
77 ; CHECK-GI-NEXT: // kill: def $d0 killed $d0 killed $q0
79 %and = and <1 x i32> %C, %B
80 %neg = xor <1 x i32> %C, <i32 -1>
81 %and1 = and <1 x i32> %neg, %A
82 %or = or <1 x i32> %and, %and1
86 ; 64-bit vectors tests
88 define <1 x i64> @test_bit_v1i64(<1 x i64> %A, <1 x i64> %B, <1 x i64> %C) {
89 ; CHECK-SD-LABEL: test_bit_v1i64:
91 ; CHECK-SD-NEXT: bit v0.8b, v1.8b, v2.8b
94 ; CHECK-GI-LABEL: test_bit_v1i64:
96 ; CHECK-GI-NEXT: fmov x8, d2
97 ; CHECK-GI-NEXT: fmov x9, d1
98 ; CHECK-GI-NEXT: fmov x10, d0
99 ; CHECK-GI-NEXT: and x9, x8, x9
100 ; CHECK-GI-NEXT: bic x8, x10, x8
101 ; CHECK-GI-NEXT: orr x8, x9, x8
102 ; CHECK-GI-NEXT: fmov d0, x8
104 %and = and <1 x i64> %C, %B
105 %neg = xor <1 x i64> %C, <i64 -1>
106 %and1 = and <1 x i64> %neg, %A
107 %or = or <1 x i64> %and, %and1
111 define <2 x i32> @test_bit_v2i32(<2 x i32> %A, <2 x i32> %B, <2 x i32> %C) {
112 ; CHECK-LABEL: test_bit_v2i32:
114 ; CHECK-NEXT: bit v0.8b, v1.8b, v2.8b
116 %and = and <2 x i32> %C, %B
117 %neg = xor <2 x i32> %C, <i32 -1, i32 -1>
118 %and1 = and <2 x i32> %neg, %A
119 %or = or <2 x i32> %and, %and1
123 define <4 x i16> @test_bit_v4i16(<4 x i16> %A, <4 x i16> %B, <4 x i16> %C) {
124 ; CHECK-LABEL: test_bit_v4i16:
126 ; CHECK-NEXT: bit v0.8b, v1.8b, v2.8b
128 %and = and <4 x i16> %C, %B
129 %neg = xor <4 x i16> %C, <i16 -1, i16 -1, i16 -1, i16 -1>
130 %and1 = and <4 x i16> %neg, %A
131 %or = or <4 x i16> %and, %and1
135 define <8 x i8> @test_bit_v8i8(<8 x i8> %A, <8 x i8> %B, <8 x i8> %C) {
136 ; CHECK-LABEL: test_bit_v8i8:
138 ; CHECK-NEXT: bit v0.8b, v1.8b, v2.8b
140 %and = and <8 x i8> %C, %B
141 %neg = xor <8 x i8> %C, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
142 %and1 = and <8 x i8> %neg, %A
143 %or = or <8 x i8> %and, %and1
147 ; 128-bit vectors tests
149 define <2 x i64> @test_bit_v2i64(<2 x i64> %A, <2 x i64> %B, <2 x i64> %C) {
150 ; CHECK-LABEL: test_bit_v2i64:
152 ; CHECK-NEXT: bit v0.16b, v1.16b, v2.16b
154 %and = and <2 x i64> %C, %B
155 %neg = xor <2 x i64> %C, <i64 -1, i64 -1>
156 %and1 = and <2 x i64> %neg, %A
157 %or = or <2 x i64> %and, %and1
161 define <4 x i32> @test_bit_v4i32(<4 x i32> %A, <4 x i32> %B, <4 x i32> %C) {
162 ; CHECK-LABEL: test_bit_v4i32:
164 ; CHECK-NEXT: bit v0.16b, v1.16b, v2.16b
166 %and = and <4 x i32> %C, %B
167 %neg = xor <4 x i32> %C, <i32 -1, i32 -1, i32 -1, i32 -1>
168 %and1 = and <4 x i32> %neg, %A
169 %or = or <4 x i32> %and, %and1
173 define <8 x i16> @test_bit_v8i16(<8 x i16> %A, <8 x i16> %B, <8 x i16> %C) {
174 ; CHECK-LABEL: test_bit_v8i16:
176 ; CHECK-NEXT: bit v0.16b, v1.16b, v2.16b
178 %and = and <8 x i16> %C, %B
179 %neg = xor <8 x i16> %C, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
180 %and1 = and <8 x i16> %neg, %A
181 %or = or <8 x i16> %and, %and1
185 define <16 x i8> @test_bit_v16i8(<16 x i8> %A, <16 x i8> %B, <16 x i8> %C) {
186 ; CHECK-LABEL: test_bit_v16i8:
188 ; CHECK-NEXT: bit v0.16b, v1.16b, v2.16b
190 %and = and <16 x i8> %C, %B
191 %neg = xor <16 x i8> %C, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
192 %and1 = and <16 x i8> %neg, %A
193 %or = or <16 x i8> %and, %and1
197 define <4 x i32> @test_bit_sink_operand(<4 x i32> %src, <4 x i32> %dst, <4 x i32> %mask, i32 %scratch) {
198 ; CHECK-LABEL: test_bit_sink_operand:
199 ; CHECK: // %bb.0: // %entry
200 ; CHECK-NEXT: sub sp, sp, #32
201 ; CHECK-NEXT: .cfi_def_cfa_offset 32
202 ; CHECK-NEXT: cmp w0, #0
203 ; CHECK-NEXT: mov w9, wzr
204 ; CHECK-NEXT: cinc w8, w0, lt
205 ; CHECK-NEXT: asr w8, w8, #1
206 ; CHECK-NEXT: .LBB11_1: // %do.body
207 ; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
208 ; CHECK-NEXT: bit v1.16b, v0.16b, v2.16b
209 ; CHECK-NEXT: add x10, sp, #16
210 ; CHECK-NEXT: mov x11, sp
211 ; CHECK-NEXT: bfi x10, x9, #2, #2
212 ; CHECK-NEXT: bfi x11, x9, #2, #2
213 ; CHECK-NEXT: add w9, w9, #1
214 ; CHECK-NEXT: cmp w9, #5
215 ; CHECK-NEXT: str q1, [sp, #16]
216 ; CHECK-NEXT: str w0, [x10]
217 ; CHECK-NEXT: ldr q1, [sp, #16]
218 ; CHECK-NEXT: str q0, [sp]
219 ; CHECK-NEXT: str w8, [x11]
220 ; CHECK-NEXT: ldr q0, [sp]
221 ; CHECK-NEXT: b.ne .LBB11_1
222 ; CHECK-NEXT: // %bb.2: // %do.end
223 ; CHECK-NEXT: mov v0.16b, v1.16b
224 ; CHECK-NEXT: add sp, sp, #32
228 %0 = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
229 %div = sdiv i32 %scratch, 2
233 %dst.addr.0 = phi <4 x i32> [ %dst, %entry ], [ %vecins, %do.body ]
234 %src.addr.0 = phi <4 x i32> [ %src, %entry ], [ %vecins1, %do.body ]
235 %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
236 %vbsl3.i = and <4 x i32> %src.addr.0, %mask
237 %vbsl4.i = and <4 x i32> %dst.addr.0, %0
238 %vbsl5.i = or <4 x i32> %vbsl3.i, %vbsl4.i
239 %vecins = insertelement <4 x i32> %vbsl5.i, i32 %scratch, i32 %i.0
240 %vecins1 = insertelement <4 x i32> %src.addr.0, i32 %div, i32 %i.0
241 %inc = add nuw nsw i32 %i.0, 1
242 %exitcond.not = icmp eq i32 %inc, 5
243 br i1 %exitcond.not, label %do.end, label %do.body
246 ret <4 x i32> %vecins