[llvm] [RISCV] Add packw+packh isel pattern for unaligned loads on RV64. (PR #152159)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 5 08:35:36 PDT 2025


================
@@ -661,6 +661,16 @@ def : Pat<(binop_allwusers<or> (shl GPR:$rs2, (i64 16)),
 def : Pat<(i64 (or (sext_inreg (shl GPR:$rs2, (i64 16)), i32),
                    (zexti16 (i64 GPR:$rs1)))),
           (PACKW GPR:$rs1, GPR:$rs2)>;
+
+// Match a pattern of 2 bytes being inserted into bits [31:16], with bits
+// bits [15:0] coming from a zero extended value, and bits [63:32] being
+// ignored. We can use packw with packh for bits [31:16]. If bits [15:0] can
+// also be a packh, it can be matched separately.
+def : Pat<(binop_allwusers<or>
+               (or (shl (zexti8 (XLenVT GPR:$op1rs2)), (XLenVT 24)),
+                   (shl (zexti8 (XLenVT GPR:$op1rs1)), (XLenVT 16))),
+               (XLenVT GPR:$rs1)),
----------------
topperc wrote:

Oops I missed the zexti16 here.

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


More information about the llvm-commits mailing list