[llvm] [AArch64][GlobalISel] Match SelectionDAG lowering for vshll_n and vshll_high_n intrinsics (PR #214449)

David Green via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 07:54:39 PDT 2026


================
@@ -9553,19 +9553,41 @@ def : Pat<(v4i32 (concat_vectors (v2i32 V64:$Rd),
           (SHRNv4i32_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
                            V128:$Rn, vecshiftR32Narrow:$imm)>;
 
-def : Pat<(shl (v8i16 (zext (v8i8 V64:$Rm))), (v8i16 (AArch64dup (i32 imm32_0_7:$size)))),
-          (USHLLv8i8_shift V64:$Rm, (i32 imm32_0_7:$size))>;
-def : Pat<(shl (v4i32 (zext (v4i16 V64:$Rm))), (v4i32 (AArch64dup (i32 imm32_0_15:$size)))),
-          (USHLLv4i16_shift V64:$Rm, (i32 imm32_0_15:$size))>;
-def : Pat<(shl (v2i64 (zext (v2i32 V64:$Rm))), (v2i64 (AArch64dup (i64 imm0_31:$size)))),
-          (USHLLv2i32_shift V64:$Rm, (trunc_imm imm0_31:$size))>;
-
-def : Pat<(shl (v8i16 (sext (v8i8 V64:$Rm))), (v8i16 (AArch64dup (i32 imm32_0_7:$size)))),
-          (SSHLLv8i8_shift V64:$Rm, (i32 imm32_0_7:$size))>;
-def : Pat<(shl (v4i32 (sext (v4i16 V64:$Rm))), (v4i32 (AArch64dup (i32 imm32_0_15:$size)))),
-          (SSHLLv4i16_shift V64:$Rm, (i32 imm32_0_15:$size))>;
-def : Pat<(shl (v2i64 (sext (v2i32 V64:$Rm))), (v2i64 (AArch64dup (i64 imm0_31:$size)))),
-          (SSHLLv2i32_shift V64:$Rm, (trunc_imm imm0_31:$size))>;
+multiclass WidenShiftImmPats<string inst, SDPatternOperator ext> {
+  def : Pat<(shl (v8i16 (ext (v8i8 V64:$Rm))), (v8i16 (AArch64dup (i32 imm32_0_7:$size)))),
+          (!cast<Instruction>(inst#"v8i8_shift") V64:$Rm, (i32 imm32_0_7:$size))>;
+  def : Pat<(shl (v4i32 (ext (v4i16 V64:$Rm))), (v4i32 (AArch64dup (i32 imm32_0_15:$size)))),
+          (!cast<Instruction>(inst#"v4i16_shift") V64:$Rm, (i32 imm32_0_15:$size))>;
+  def : Pat<(shl (v2i64 (ext (v2i32 V64:$Rm))), (v2i64 (AArch64dup (i64 imm0_31:$size)))),
+          (!cast<Instruction>(inst#"v2i32_shift") V64:$Rm, (trunc_imm imm0_31:$size))>;
+
+  def : Pat<(shl (v8i16 (ext (extract_high_v16i8 (v16i8 V128:$Rn)))), (v8i16 (AArch64dup (i32 imm32_0_7:$size)))),
+          (!cast<Instruction>(inst#"v16i8_shift") V128:$Rn, (i32 imm32_0_7:$size))>;
+  def : Pat<(shl (v4i32 (ext (extract_high_v8i16 (v8i16 V128:$Rn)))), (v4i32 (AArch64dup (i32 imm32_0_15:$size)))),
+          (!cast<Instruction>(inst#"v8i16_shift") V128:$Rn, (i32 imm32_0_15:$size))>;
+  def : Pat<(shl (v2i64 (ext (extract_high_v4i32 (v4i32 V128:$Rn)))), (v2i64 (AArch64dup (i64 imm0_31:$size)))),
+          (!cast<Instruction>(inst#"v4i32_shift") V128:$Rn, (trunc_imm imm0_31:$size))>;
+}
+defm : WidenShiftImmPats<"SSHLL", sext>;
+defm : WidenShiftImmPats<"USHLL", zext>;
----------------
davemgreen wrote:

Could you add anyext here too? In case it comes up

https://github.com/llvm/llvm-project/pull/214449


More information about the llvm-commits mailing list