[llvm] [AArch64][SelectionDAG] Lower multiplication by a constant to shl+sub+shl+sub (PR #90199)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 26 12:58:58 PDT 2024


================
@@ -17611,6 +17628,8 @@ static SDValue performMulCombine(SDNode *N, SelectionDAG &DAG,
     //     => MV = (add (shl x, M), x); (add (shl MV, N), MV)
     // (mul x, (2^M + 1) * 2^N + 1))
     //     =>  MV = add (shl x, M), x); add (shl MV, N), x)
+    // (mul x, 1 - (1 - 2^M) * 2^N))
+    //     =>  MV = sub (x - (shl x, M)); add (x - (shl x, M))
----------------
efriedma-quic wrote:

Formula looks inconsistent with other formulas.

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


More information about the llvm-commits mailing list