Skip to content

Commit 023dd34

Browse files
committed
[AARch64] Funnel Shift now uses rev32/rev64 instructions
1 parent c2ae572 commit 023dd34

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.td

+8
Original file line numberDiff line numberDiff line change
@@ -5679,6 +5679,14 @@ def : Pat<(v4i32 (bswap (v4i32 V128:$Rn))),
56795679
def : Pat<(v2i64 (bswap (v2i64 V128:$Rn))),
56805680
(v2i64 (REV64v16i8 (v2i64 V128:$Rn)))>;
56815681

5682+
// Patterns for funnel shifts to be matched to equivalent REV instructions
5683+
def : Pat<(v2i64 (or (v2i64 (AArch64vshl (v2i64 V128:$Rn), (i32 32))), (v2i64 (AArch64vlshr (v2i64 V128:$Rn), (i32 32))))),
5684+
(v2i64 (REV64v4i32 (v2i64 V128:$Rn)))>;
5685+
def : Pat<(v4i32 (or (v4i32 (AArch64vshl (v4i32 V128:$Rn), (i32 16))), (v4i32 (AArch64vlshr (v4i32 V128:$Rn), (i32 16))))),
5686+
(v4i32 (REV32v8i16 (v4i32 V128:$Rn)))>;
5687+
def : Pat<(v2i32 (or (v2i32 (AArch64vshl (v2i32 V64:$Rn), (i32 16))), (v2i32 (AArch64vlshr (v2i32 V64:$Rn), (i32 16))))),
5688+
(v2i32 (REV32v4i16 (v2i32 V64:$Rn)))>;
5689+
56825690
//===----------------------------------------------------------------------===//
56835691
// Advanced SIMD three vector instructions.
56845692
//===----------------------------------------------------------------------===//
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
3+
4+
define <2 x i64> @fhsl_to_rev2i64(<2 x i64> %r) {
5+
; CHECK-LABEL: fhsl_to_rev2i64:
6+
; CHECK: // %bb.0:
7+
; CHECK-NEXT: rev64 v0.4s, v0.4s
8+
; CHECK-NEXT: ret
9+
%or = tail call <2 x i64> @llvm.fshl.v2i64(<2 x i64> %r, <2 x i64> %r, <2 x i64> splat (i64 32))
10+
ret <2 x i64> %or
11+
}
12+
13+
define <4 x i32> @fshl_to_rev4i32(<4 x i32> %r) {
14+
; CHECK-LABEL: fshl_to_rev4i32:
15+
; CHECK: // %bb.0:
16+
; CHECK-NEXT: rev32 v0.8h, v0.8h
17+
; CHECK-NEXT: ret
18+
%or = tail call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %r, <4 x i32> %r, <4 x i32> splat (i32 16))
19+
ret <4 x i32> %or
20+
}
21+
22+
define <2 x i32> @fshl_to_rev2i32(<2 x i32> %r) {
23+
; CHECK-LABEL: fshl_to_rev2i32:
24+
; CHECK: // %bb.0:
25+
; CHECK-NEXT: rev32 v0.4h, v0.4h
26+
; CHECK-NEXT: ret
27+
%or = tail call <2 x i32> @llvm.fshl.v2i32(<2 x i32> %r, <2 x i32> %r, <2 x i32> splat (i32 16))
28+
ret <2 x i32> %or
29+
}

0 commit comments

Comments
 (0)