[llvm] [RISCV] Add `2^N + 2^M` expanding pattern for mul (PR #137195)

Iris Shi via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 24 23:44:42 PDT 2025


el-ev wrote:

> Should we be solving the general case? What if there are more than 2 bits set in the multiplicand?

I'm not sure whether it's profitable enough to break down a mul into more than two `shl`s, and we observe that other backends typically don't perform this general level of optimization either.

However, it may be beneficial if the mul could be break down to a `shl + shladd + add` sequence. This could be a potential enhancement for a following patch.

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


More information about the llvm-commits mailing list