[llvm] [RISCV] Strength reduce mul by 2^N - 2^M (PR #88983)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 00:18:14 PDT 2024


================
@@ -13474,6 +13476,19 @@ static SDValue expandMul(SDNode *N, SelectionDAG &DAG,
     }
   }
 
+  // 2^N - 2^M -> (sub (shl X, C1), (shl X, C2))
----------------
dtcxzyw wrote:

BTW, I think it is time to switch to search-based methods. I believe it will address @wangpc-pp's [concern](https://github.com/llvm/llvm-project/pull/88993#discussion_r1568243508) about the cost model :)

References:
> Bernstein, Robert. "Multiplication by Integer Constants." Software—Practice and Experience 16, 7 (July 1986), 641–652.

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


More information about the llvm-commits mailing list