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 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SD
; RUN: llc -mtriple=aarch64 -global-isel %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-GI
; ====== Scalar Tests =====
; ====== Scalar bswap.i16 Tests =====
define i16 @bswap_i16_to_i16_anyext(i16 %a){
; CHECK-SD-LABEL: bswap_i16_to_i16_anyext:
; CHECK-SD: // %bb.0:
; CHECK-SD-NEXT: rev16 w0, w0
; CHECK-SD-NEXT: ret
;
; CHECK-GI-LABEL: bswap_i16_to_i16_anyext:
; CHECK-GI: // %bb.0:
; CHECK-GI-NEXT: rev w8, w0
; CHECK-GI-NEXT: lsr w0, w8, #16
; CHECK-GI-NEXT: ret
%3 = call i16 @llvm.bswap.i16(i16 %a)
ret i16 %3
}
declare i16 @llvm.bswap.i16(i16)
; The zext here is optimised to an any_extend during isel.
define i64 @bswap_i16_to_i64_anyext(i16 %a) {
; CHECK-SD-LABEL: bswap_i16_to_i64_anyext:
; CHECK-SD: // %bb.0:
; CHECK-SD-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-SD-NEXT: rev16 x8, x0
; CHECK-SD-NEXT: lsl x0, x8, #48
; CHECK-SD-NEXT: ret
;
; CHECK-GI-LABEL: bswap_i16_to_i64_anyext:
; CHECK-GI: // %bb.0:
; CHECK-GI-NEXT: rev w8, w0
; CHECK-GI-NEXT: lsr w8, w8, #16
; CHECK-GI-NEXT: and x8, x8, #0xffff
; CHECK-GI-NEXT: lsl x0, x8, #48
; CHECK-GI-NEXT: ret
%3 = call i16 @llvm.bswap.i16(i16 %a)
%4 = zext i16 %3 to i64
%5 = shl i64 %4, 48
ret i64 %5
}
; The zext here is optimised to an any_extend during isel..
define i128 @bswap_i16_to_i128_anyext(i16 %a) {
; CHECK-SD-LABEL: bswap_i16_to_i128_anyext:
; CHECK-SD: // %bb.0:
; CHECK-SD-NEXT: mov w8, w0
; CHECK-SD-NEXT: mov x0, xzr
; CHECK-SD-NEXT: rev w8, w8
; CHECK-SD-NEXT: lsr w8, w8, #16
; CHECK-SD-NEXT: lsl x1, x8, #48
; CHECK-SD-NEXT: ret
;
; CHECK-GI-LABEL: bswap_i16_to_i128_anyext:
; CHECK-GI: // %bb.0:
; CHECK-GI-NEXT: mov w8, w0
; CHECK-GI-NEXT: mov x0, xzr
; CHECK-GI-NEXT: rev w8, w8
; CHECK-GI-NEXT: lsr w8, w8, #16
; CHECK-GI-NEXT: and x8, x8, #0xffff
; CHECK-GI-NEXT: lsl x1, x8, #48
; CHECK-GI-NEXT: ret
%3 = call i16 @llvm.bswap.i16(i16 %a)
%4 = zext i16 %3 to i128
%5 = shl i128 %4, 112
ret i128 %5
}
define i32 @bswap_i16_to_i32_zext(i16 %a){
; CHECK-LABEL: bswap_i16_to_i32_zext:
; CHECK: // %bb.0:
; CHECK-NEXT: rev w8, w0
; CHECK-NEXT: lsr w0, w8, #16
; CHECK-NEXT: ret
%3 = call i16 @llvm.bswap.i16(i16 %a)
%4 = zext i16 %3 to i32
ret i32 %4
}
; ====== Other scalar bswap tests =====
define i32 @bswap_i32(i32 %a){
; CHECK-LABEL: bswap_i32:
; CHECK: // %bb.0:
; CHECK-NEXT: rev w0, w0
; CHECK-NEXT: ret
%3 = call i32 @llvm.bswap.i32(i32 %a)
ret i32 %3
}
declare i32 @llvm.bswap.i32(i32)
define i64 @bswap_i64(i64 %a){
; CHECK-LABEL: bswap_i64:
; CHECK: // %bb.0:
; CHECK-NEXT: rev x0, x0
; CHECK-NEXT: ret
%3 = call i64 @llvm.bswap.i64(i64 %a)
ret i64 %3
}
declare i64 @llvm.bswap.i64(i64)
define i128 @bswap_i128(i128 %a){
; CHECK-LABEL: bswap_i128:
; CHECK: // %bb.0:
; CHECK-NEXT: rev x8, x1
; CHECK-NEXT: rev x1, x0
; CHECK-NEXT: mov x0, x8
; CHECK-NEXT: ret
%3 = call i128 @llvm.bswap.i128(i128 %a)
ret i128 %3
}
declare i128 @llvm.bswap.i128(i128)
; ===== Legal Vector Type Tests =====
define <4 x i16> @bswap_v4i16(<4 x i16> %a){
; CHECK-LABEL: bswap_v4i16:
; CHECK: // %bb.0:
; CHECK-NEXT: rev16 v0.8b, v0.8b
; CHECK-NEXT: ret
%3 = call <4 x i16> @llvm.bswap.v4i16(<4 x i16> %a)
ret <4 x i16> %3
}
declare <4 x i16> @llvm.bswap.v4i16(<4 x i16>)
define <8 x i16> @bswap_v8i16(<8 x i16> %a){
; CHECK-LABEL: bswap_v8i16:
; CHECK: // %bb.0:
; CHECK-NEXT: rev16 v0.16b, v0.16b
; CHECK-NEXT: ret
%3 = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
ret <8 x i16> %3
}
declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>)
define <2 x i32> @bswap_v2i32(<2 x i32> %a){
; CHECK-LABEL: bswap_v2i32:
; CHECK: // %bb.0:
; CHECK-NEXT: rev32 v0.8b, v0.8b
; CHECK-NEXT: ret
%3 = call <2 x i32> @llvm.bswap.v2i32(<2 x i32> %a)
ret <2 x i32> %3
}
declare <2 x i32> @llvm.bswap.v2i32(<2 x i32>)
define <4 x i32> @bswap_v4i32(<4 x i32> %a){
; CHECK-LABEL: bswap_v4i32:
; CHECK: // %bb.0:
; CHECK-NEXT: rev32 v0.16b, v0.16b
; CHECK-NEXT: ret
%3 = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
ret <4 x i32> %3
}
declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
define <2 x i64> @bswap_v2i64(<2 x i64> %a){
; CHECK-LABEL: bswap_v2i64:
; CHECK: // %bb.0:
; CHECK-NEXT: rev64 v0.16b, v0.16b
; CHECK-NEXT: ret
%3 = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
ret <2 x i64> %3
}
declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
; ===== Smaller/Larger Width Vectors with Legal Element Sizes =====
define <2 x i16> @bswap_v2i16(<2 x i16> %a){
; CHECK-SD-LABEL: bswap_v2i16:
; CHECK-SD: // %bb.0: // %entry
; CHECK-SD-NEXT: rev32 v0.8b, v0.8b
; CHECK-SD-NEXT: ushr v0.2s, v0.2s, #16
; CHECK-SD-NEXT: ret
;
; CHECK-GI-LABEL: bswap_v2i16:
; CHECK-GI: // %bb.0: // %entry
; CHECK-GI-NEXT: uzp1 v0.4h, v0.4h, v0.4h
; CHECK-GI-NEXT: rev16 v0.8b, v0.8b
; CHECK-GI-NEXT: ushll v0.4s, v0.4h, #0
; CHECK-GI-NEXT: // kill: def $d0 killed $d0 killed $q0
; CHECK-GI-NEXT: ret
entry:
%res = call <2 x i16> @llvm.bswap.v2i16(<2 x i16> %a)
ret <2 x i16> %res
}
declare <2 x i16> @llvm.bswap.v2i16(<2 x i16>)
define <16 x i16> @bswap_v16i16(<16 x i16> %a){
; CHECK-LABEL: bswap_v16i16:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: rev16 v0.16b, v0.16b
; CHECK-NEXT: rev16 v1.16b, v1.16b
; CHECK-NEXT: ret
entry:
%res = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
ret <16 x i16> %res
}
declare <16 x i16> @llvm.bswap.v16i16(<16 x i16>)
define <1 x i32> @bswap_v1i32(<1 x i32> %a){
; CHECK-SD-LABEL: bswap_v1i32:
; CHECK-SD: // %bb.0: // %entry
; CHECK-SD-NEXT: rev32 v0.8b, v0.8b
; CHECK-SD-NEXT: ret
;
; CHECK-GI-LABEL: bswap_v1i32:
; CHECK-GI: // %bb.0: // %entry
; CHECK-GI-NEXT: fmov w8, s0
; CHECK-GI-NEXT: rev w8, w8
; CHECK-GI-NEXT: mov v0.s[0], w8
; CHECK-GI-NEXT: // kill: def $d0 killed $d0 killed $q0
; CHECK-GI-NEXT: ret
entry:
%res = call <1 x i32> @llvm.bswap.v1i32(<1 x i32> %a)
ret <1 x i32> %res
}
declare <1 x i32> @llvm.bswap.v1i32(<1 x i32>)
define <8 x i32> @bswap_v8i32(<8 x i32> %a){
; CHECK-LABEL: bswap_v8i32:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: rev32 v0.16b, v0.16b
; CHECK-NEXT: rev32 v1.16b, v1.16b
; CHECK-NEXT: ret
entry:
%res = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
ret <8 x i32> %res
}
declare <8 x i32> @llvm.bswap.v8i32(<8 x i32>)
define <4 x i64> @bswap_v4i64(<4 x i64> %a){
; CHECK-LABEL: bswap_v4i64:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: rev64 v0.16b, v0.16b
; CHECK-NEXT: rev64 v1.16b, v1.16b
; CHECK-NEXT: ret
entry:
%res = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
ret <4 x i64> %res
}
declare <4 x i64> @llvm.bswap.v4i64(<4 x i64>)
; ===== Vectors with Non-Pow 2 Widths =====
define <3 x i16> @bswap_v3i16(<3 x i16> %a){
; CHECK-LABEL: bswap_v3i16:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: rev16 v0.8b, v0.8b
; CHECK-NEXT: ret
entry:
%res = call <3 x i16> @llvm.bswap.v3i16(<3 x i16> %a)
ret <3 x i16> %res
}
declare <3 x i16> @llvm.bswap.v3i16(<3 x i16>)
define <7 x i16> @bswap_v7i16(<7 x i16> %a){
; CHECK-LABEL: bswap_v7i16:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: rev16 v0.16b, v0.16b
; CHECK-NEXT: ret
entry:
%res = call <7 x i16> @llvm.bswap.v7i16(<7 x i16> %a)
ret <7 x i16> %res
}
declare <7 x i16> @llvm.bswap.v7i16(<7 x i16>)
define <3 x i32> @bswap_v3i32(<3 x i32> %a){
; CHECK-LABEL: bswap_v3i32:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: rev32 v0.16b, v0.16b
; CHECK-NEXT: ret
entry:
%res = call <3 x i32> @llvm.bswap.v3i32(<3 x i32> %a)
ret <3 x i32> %res
}
declare <3 x i32> @llvm.bswap.v3i32(<3 x i32>)
|