[llvm] [AArch64][SVE] Use ADD/ADR instead of MUL/MLA for x*N (PR #198566)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 09:23:01 PDT 2026


================
@@ -1948,6 +1948,121 @@ let Predicates = [HasSVE] in {
   defm : adrShiftPat<nxv4i32, nxv4i1, i32, ADR_LSL_ZZZ_S_2, 2>;
   defm : adrShiftPat<nxv4i32, nxv4i1, i32, ADR_LSL_ZZZ_S_3, 3>;
 
+  // Avoid MUL/MLA for small constants where ADD/ADR forms are available.
+  multiclass sveMulImmAddAdrPat<ValueType Ty, ValueType PredTy,
+                                ValueType ScalarTy, Instruction Add,
+                                Instruction Adr1, Instruction Adr2,
+                                Instruction Adr3> {
+    def : Pat<(Ty (AArch64mul_m1 (PredTy (SVEAllActive)), Ty:$Op,
+                                  (Ty (splat_vector (ScalarTy 2))))),
+              (Add $Op, $Op)>;
----------------
paulwalker-arm wrote:

You shouldn't need the `SVEAllActive` related patterns because InstCombiner will canonicalise most `op(all_active,...` to `op_u(all_active,...`.

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


More information about the llvm-commits mailing list