File: aarch64-bit-gen.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (198 lines) | stat: -rw-r--r-- 6,213 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s

; BIT Bitwise Insert if True
;
; 8-bit vectors tests

define <1 x i8> @test_bit_v1i8(<1 x i8> %A, <1 x i8> %B, <1 x i8> %C) {
; CHECK-LABEL: test_bit_v1i8:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.8b, v1.8b, v2.8b
; CHECK-NEXT:    ret
  %and = and <1 x i8> %C, %B
  %neg = xor <1 x i8> %C, <i8 -1>
  %and1 = and <1 x i8> %neg, %A
  %or = or <1 x i8> %and, %and1
  ret <1 x i8> %or
}

; 16-bit vectors tests

define <1 x i16> @test_bit_v1i16(<1 x i16> %A, <1 x i16> %B, <1 x i16> %C) {
; CHECK-LABEL: test_bit_v1i16:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.8b, v1.8b, v2.8b
; CHECK-NEXT:    ret
  %and = and <1 x i16> %C, %B
  %neg = xor <1 x i16> %C, <i16 -1>
  %and1 = and <1 x i16> %neg, %A
  %or = or <1 x i16> %and, %and1
  ret <1 x i16> %or
}

; 32-bit vectors tests

define <1 x i32> @test_bit_v1i32(<1 x i32> %A, <1 x i32> %B, <1 x i32> %C) {
; CHECK-LABEL: test_bit_v1i32:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.8b, v1.8b, v2.8b
; CHECK-NEXT:    ret
  %and = and <1 x i32> %C, %B
  %neg = xor <1 x i32> %C, <i32 -1>
  %and1 = and <1 x i32> %neg, %A
  %or = or <1 x i32> %and, %and1
  ret <1 x i32> %or
}

; 64-bit vectors tests

define <1 x i64> @test_bit_v1i64(<1 x i64> %A, <1 x i64> %B, <1 x i64> %C) {
; CHECK-LABEL: test_bit_v1i64:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.8b, v1.8b, v2.8b
; CHECK-NEXT:    ret
  %and = and <1 x i64> %C, %B
  %neg = xor <1 x i64> %C, <i64 -1>
  %and1 = and <1 x i64> %neg, %A
  %or = or <1 x i64> %and, %and1
  ret <1 x i64> %or
}

define <2 x i32> @test_bit_v2i32(<2 x i32> %A, <2 x i32> %B, <2 x i32> %C) {
; CHECK-LABEL: test_bit_v2i32:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.8b, v1.8b, v2.8b
; CHECK-NEXT:    ret
  %and = and <2 x i32> %C, %B
  %neg = xor <2 x i32> %C, <i32 -1, i32 -1>
  %and1 = and <2 x i32> %neg, %A
  %or = or <2 x i32> %and, %and1
  ret <2 x i32> %or
}

define <4 x i16> @test_bit_v4i16(<4 x i16> %A, <4 x i16> %B, <4 x i16> %C) {
; CHECK-LABEL: test_bit_v4i16:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.8b, v1.8b, v2.8b
; CHECK-NEXT:    ret
  %and = and <4 x i16> %C, %B
  %neg = xor <4 x i16> %C, <i16 -1, i16 -1, i16 -1, i16 -1>
  %and1 = and <4 x i16> %neg, %A
  %or = or <4 x i16> %and, %and1
  ret <4 x i16> %or
}

define <8 x i8> @test_bit_v8i8(<8 x i8> %A, <8 x i8> %B, <8 x i8> %C) {
; CHECK-LABEL: test_bit_v8i8:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.8b, v1.8b, v2.8b
; CHECK-NEXT:    ret
  %and = and <8 x i8> %C, %B
  %neg = xor <8 x i8> %C, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
  %and1 = and <8 x i8> %neg, %A
  %or = or <8 x i8> %and, %and1
  ret <8 x i8> %or
}

; 128-bit vectors tests

define <2 x i64> @test_bit_v2i64(<2 x i64> %A, <2 x i64> %B, <2 x i64> %C) {
; CHECK-LABEL: test_bit_v2i64:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.16b, v1.16b, v2.16b
; CHECK-NEXT:    ret
  %and = and <2 x i64> %C, %B
  %neg = xor <2 x i64> %C, <i64 -1, i64 -1>
  %and1 = and <2 x i64> %neg, %A
  %or = or <2 x i64> %and, %and1
  ret <2 x i64> %or
}

define <4 x i32> @test_bit_v4i32(<4 x i32> %A, <4 x i32> %B, <4 x i32> %C) {
; CHECK-LABEL: test_bit_v4i32:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.16b, v1.16b, v2.16b
; CHECK-NEXT:    ret
  %and = and <4 x i32> %C, %B
  %neg = xor <4 x i32> %C, <i32 -1, i32 -1, i32 -1, i32 -1>
  %and1 = and <4 x i32> %neg, %A
  %or = or <4 x i32> %and, %and1
  ret <4 x i32> %or
}

define <8 x i16> @test_bit_v8i16(<8 x i16> %A, <8 x i16> %B, <8 x i16> %C) {
; CHECK-LABEL: test_bit_v8i16:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.16b, v1.16b, v2.16b
; CHECK-NEXT:    ret
  %and = and <8 x i16> %C, %B
  %neg = xor <8 x i16> %C, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
  %and1 = and <8 x i16> %neg, %A
  %or = or <8 x i16> %and, %and1
  ret <8 x i16> %or
}

define <16 x i8> @test_bit_v16i8(<16 x i8> %A, <16 x i8> %B, <16 x i8> %C) {
; CHECK-LABEL: test_bit_v16i8:
; CHECK:       // %bb.0:
; CHECK-NEXT:    bit v0.16b, v1.16b, v2.16b
; CHECK-NEXT:    ret
  %and = and <16 x i8> %C, %B
  %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>
  %and1 = and <16 x i8> %neg, %A
  %or = or <16 x i8> %and, %and1
  ret <16 x i8> %or
}

define <4 x i32> @test_bit_sink_operand(<4 x i32> %src, <4 x i32> %dst, <4 x i32> %mask, i32 %scratch) {
; CHECK-LABEL: test_bit_sink_operand:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    sub sp, sp, #32
; CHECK-NEXT:    .cfi_def_cfa_offset 32
; CHECK-NEXT:    cmp w0, #0
; CHECK-NEXT:    mov w8, wzr
; CHECK-NEXT:    cinc w9, w0, lt
; CHECK-NEXT:    asr w9, w9, #1
; CHECK-NEXT:  .LBB11_1: // %do.body
; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    bit v1.16b, v0.16b, v2.16b
; CHECK-NEXT:    add x10, sp, #16
; CHECK-NEXT:    bfi x10, x8, #2, #2
; CHECK-NEXT:    mov x11, sp
; CHECK-NEXT:    bfi x11, x8, #2, #2
; CHECK-NEXT:    add w8, w8, #1
; CHECK-NEXT:    cmp w8, #5
; CHECK-NEXT:    str q1, [sp, #16]
; CHECK-NEXT:    str w0, [x10]
; CHECK-NEXT:    ldr q1, [sp, #16]
; CHECK-NEXT:    str q0, [sp]
; CHECK-NEXT:    str w9, [x11]
; CHECK-NEXT:    ldr q0, [sp]
; CHECK-NEXT:    b.ne .LBB11_1
; CHECK-NEXT:  // %bb.2: // %do.end
; CHECK-NEXT:    mov v0.16b, v1.16b
; CHECK-NEXT:    add sp, sp, #32
; CHECK-NEXT:    ret

entry:
  %0 = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
  %div = sdiv i32 %scratch, 2
  br label %do.body

do.body:
  %dst.addr.0 = phi <4 x i32> [ %dst, %entry ], [ %vecins, %do.body ]
  %src.addr.0 = phi <4 x i32> [ %src, %entry ], [ %vecins1, %do.body ]
  %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
  %vbsl3.i = and <4 x i32> %src.addr.0, %mask
  %vbsl4.i = and <4 x i32> %dst.addr.0, %0
  %vbsl5.i = or <4 x i32> %vbsl3.i, %vbsl4.i
  %vecins = insertelement <4 x i32> %vbsl5.i, i32 %scratch, i32 %i.0
  %vecins1 = insertelement <4 x i32> %src.addr.0, i32 %div, i32 %i.0
  %inc = add nuw nsw i32 %i.0, 1
  %exitcond.not = icmp eq i32 %inc, 5
  br i1 %exitcond.not, label %do.end, label %do.body

do.end:
  ret <4 x i32> %vecins
}