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

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 28 05:19:07 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))
----------------
vfdff wrote:

Updated, it is `MV = sub (x - (shl x, M)); add (x - (shl MV, N))`, thanks.

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


More information about the llvm-commits mailing list