[llvm] 2b462eb - [AArch64] More patterns to generate LD1R vector splats
Sjoerd Meijer via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 1 02:48:34 PST 2023
Author: Sjoerd Meijer
Date: 2023-03-01T10:48:13Z
New Revision: 2b462eb98d6777a2fb9385eea74bab9a5a6d3b95
URL: https://github.com/llvm/llvm-project/commit/2b462eb98d6777a2fb9385eea74bab9a5a6d3b95
DIFF: https://github.com/llvm/llvm-project/commit/2b462eb98d6777a2fb9385eea74bab9a5a6d3b95.diff
LOG: [AArch64] More patterns to generate LD1R vector splats
We are missing patterns to generate vector splats using LD1R. A shuffle vector
with all 0s is a vector splat if the operands are a load and undef for which
we can generate a LD1R.
Differential Revision: https://reviews.llvm.org/D145004
Added:
Modified:
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/test/CodeGen/AArch64/neon-vector-splat.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index d5e194a9ddc9..993f6494114a 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -7269,6 +7269,22 @@ def : Pat<(v2i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
(LD1Rv2d GPR64sp:$Rn)>;
def : Pat<(v1i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
(LD1Rv1d GPR64sp:$Rn)>;
+
+def : Pat<(v8i8 (AArch64duplane8 (v16i8 (insert_subvector undef, (v8i8 (load GPR64sp:$Rn)), (i64 0))), (i64 0))),
+ (LD1Rv8b GPR64sp:$Rn)>;
+def : Pat<(v16i8 (AArch64duplane8 (v16i8 (load GPR64sp:$Rn)), (i64 0))),
+ (LD1Rv16b GPR64sp:$Rn)>;
+def : Pat<(v4i16 (AArch64duplane16 (v8i16 (insert_subvector undef, (v4i16 (load GPR64sp:$Rn)), (i64 0))), (i64 0))),
+ (LD1Rv4h GPR64sp:$Rn)>;
+def : Pat<(v8i16 (AArch64duplane16 (v8i16 (load GPR64sp:$Rn)), (i64 0))),
+ (LD1Rv8h GPR64sp:$Rn)>;
+def : Pat<(v2i32 (AArch64duplane32 (v4i32 (insert_subvector undef, (v2i32 (load GPR64sp:$Rn)), (i64 0))), (i64 0))),
+ (LD1Rv2s GPR64sp:$Rn)>;
+def : Pat<(v4i32 (AArch64duplane32 (v4i32 (load GPR64sp:$Rn)), (i64 0))),
+ (LD1Rv4s GPR64sp:$Rn)>;
+def : Pat<(v2i64 (AArch64duplane64 (v2i64 (load GPR64sp:$Rn)), (i64 0))),
+ (LD1Rv2d GPR64sp:$Rn)>;
+
// Grab the floating point version too
def : Pat<(v2f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
(LD1Rv2s GPR64sp:$Rn)>;
diff --git a/llvm/test/CodeGen/AArch64/neon-vector-splat.ll b/llvm/test/CodeGen/AArch64/neon-vector-splat.ll
index 6e6b9bdb145f..85ccdc49d437 100644
--- a/llvm/test/CodeGen/AArch64/neon-vector-splat.ll
+++ b/llvm/test/CodeGen/AArch64/neon-vector-splat.ll
@@ -4,8 +4,7 @@
define <2 x i32> @shuffle(ptr %P) {
; CHECK-LABEL: shuffle:
; CHECK: // %bb.0:
-; CHECK-NEXT: ldr d0, [x0]
-; CHECK-NEXT: dup v0.2s, v0.s[0]
+; CHECK-NEXT: ld1r { v0.2s }, [x0]
; CHECK-NEXT: ret
%lv2i32 = load <2 x i32>, ptr %P
%B = shufflevector <2 x i32> %lv2i32, <2 x i32> undef, <2 x i32> zeroinitializer
@@ -15,19 +14,32 @@ define <2 x i32> @shuffle(ptr %P) {
define <4 x i32> @shuffle2(ptr %P) {
; CHECK-LABEL: shuffle2:
; CHECK: // %bb.0:
-; CHECK-NEXT: ldr q0, [x0]
-; CHECK-NEXT: dup v0.4s, v0.s[0]
+; CHECK-NEXT: ld1r { v0.4s }, [x0]
; CHECK-NEXT: ret
%lv2i32 = load <4 x i32>, ptr %P
%B = shufflevector <4 x i32> %lv2i32, <4 x i32> undef, <4 x i32> zeroinitializer
ret <4 x i32> %B
}
+define <4 x i32> @shuffle2_multiuse(ptr %P) {
+; CHECK-LABEL: shuffle2_multiuse:
+; CHECK: // %bb.0:
+; CHECK-NEXT: ldr q0, [x0]
+; CHECK-NEXT: dup v1.4s, v0.s[0]
+; CHECK-NEXT: dup v0.4s, v0.s[1]
+; CHECK-NEXT: add v0.4s, v1.4s, v0.4s
+; CHECK-NEXT: ret
+ %lv2i32 = load <4 x i32>, ptr %P
+ %B = shufflevector <4 x i32> %lv2i32, <4 x i32> undef, <4 x i32> zeroinitializer
+ %C = shufflevector <4 x i32> %lv2i32, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
+ %D = add <4 x i32> %B, %C
+ ret <4 x i32> %D
+}
+
define <4 x i16> @shuffle3(ptr %P) {
; CHECK-LABEL: shuffle3:
; CHECK: // %bb.0:
-; CHECK-NEXT: ldr d0, [x0]
-; CHECK-NEXT: dup v0.4h, v0.h[0]
+; CHECK-NEXT: ld1r { v0.4h }, [x0]
; CHECK-NEXT: ret
%lv4i16 = load <4 x i16>, ptr %P
%sv4i16 = shufflevector <4 x i16> %lv4i16, <4 x i16> undef, <4 x i32> zeroinitializer
@@ -37,8 +49,7 @@ define <4 x i16> @shuffle3(ptr %P) {
define <8 x i16> @shuffle4(ptr %P) {
; CHECK-LABEL: shuffle4:
; CHECK: // %bb.0:
-; CHECK-NEXT: ldr q0, [x0]
-; CHECK-NEXT: dup v0.8h, v0.h[0]
+; CHECK-NEXT: ld1r { v0.8h }, [x0]
; CHECK-NEXT: ret
%lv8i16 = load <8 x i16>, ptr %P
%sv8i16 = shufflevector <8 x i16> %lv8i16, <8 x i16> undef, <8 x i32> zeroinitializer
@@ -48,8 +59,7 @@ define <8 x i16> @shuffle4(ptr %P) {
define <8 x i8> @shuffle5(ptr %P) {
; CHECK-LABEL: shuffle5:
; CHECK: // %bb.0:
-; CHECK-NEXT: ldr d0, [x0]
-; CHECK-NEXT: dup v0.8b, v0.b[0]
+; CHECK-NEXT: ld1r { v0.8b }, [x0]
; CHECK-NEXT: ret
%lv8i8 = load <8 x i8>, ptr %P
%sv8i8 = shufflevector <8 x i8> %lv8i8, <8 x i8> undef, <8 x i32> zeroinitializer
@@ -59,8 +69,7 @@ define <8 x i8> @shuffle5(ptr %P) {
define <16 x i8> @shuffle6(ptr %P) {
; CHECK-LABEL: shuffle6:
; CHECK: // %bb.0:
-; CHECK-NEXT: ldr q0, [x0]
-; CHECK-NEXT: dup v0.16b, v0.b[0]
+; CHECK-NEXT: ld1r { v0.16b }, [x0]
; CHECK-NEXT: ret
%lv16i8 = load <16 x i8>, ptr %P
%sv16i8 = shufflevector <16 x i8> %lv16i8, <16 x i8> undef, <16 x i32> zeroinitializer
@@ -70,8 +79,7 @@ define <16 x i8> @shuffle6(ptr %P) {
define <2 x i64> @shuffle7(ptr %P) {
; CHECK-LABEL: shuffle7:
; CHECK: // %bb.0:
-; CHECK-NEXT: ldr q0, [x0]
-; CHECK-NEXT: dup v0.2d, v0.d[0]
+; CHECK-NEXT: ld1r { v0.2d }, [x0]
; CHECK-NEXT: ret
%lv2i64 = load <2 x i64>, ptr %P
%sv2i64 = shufflevector <2 x i64> %lv2i64, <2 x i64> undef, <2 x i32> zeroinitializer
More information about the llvm-commits
mailing list