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

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 10:49:24 PDT 2024


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

See https://github.com/llvm/llvm-project/pull/88791 for adding ISD::SHL_ADD..  Once that lands, my hope is to common most of this code across at least x86 and RISCV.  

Please see discussion on https://github.com/llvm/llvm-project/pull/87105 with regards to decomposeMulByConsant.

As a meta point, please don't let perfection be the enemy of the good here.  :)

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


More information about the llvm-commits mailing list