[llvm] [AArch64] Optimized rdsvl followed by constant mul (PR #162853)
Kerry McLaughlin via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 21 03:48:10 PDT 2025
================
@@ -19579,6 +19579,47 @@ static SDValue performMulCombine(SDNode *N, SelectionDAG &DAG,
if (ConstValue.sge(1) && ConstValue.sle(16))
return SDValue();
+ // Multiplying an RDSVL value by a constant can sometimes be done cheaper by
+ // folding a power-of-two factor of the constant into the RDSVL immediate and
+ // compensating with an extra shift.
+ //
+ // We rewrite:
+ // (mul (srl (rdsvl 1), 3), x)
+ // to one of:
+ // (shl (rdsvl y), z) if z > 0
+ // (srl (rdsvl y), abs(z)) if z < 0
+ // where integers y, z satisfy x = y * 2^(3 + z) and y ∈ [-32, 31].
----------------
kmclaughlin-arm wrote:
Could this be moved to its own function, similar to `performMulVectorExtendCombine`, etc which are called at the beginning of `performMulCombine`?
https://github.com/llvm/llvm-project/pull/162853
More information about the llvm-commits
mailing list