[PATCH] D107711: [RISCV] Optimize (add (mul x, c0), c1)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 9 09:31:07 PDT 2021


lebedev.ri added a comment.

In D107711#2934794 <https://reviews.llvm.org/D107711#2934794>, @craig.topper wrote:

> In D107711#2934246 <https://reviews.llvm.org/D107711#2934246>, @benshi001 wrote:
>
>> Is there any better way to implement this optimization other than ISelDagToDag?
>>
>> 1. It seems hard to calculate c1/c0 by writing TD mapping rules.
>>
>> 2. I also tried DAG transform in `RISCVTargetLowering::ReplaceNodeResults`, it is also not easy, since it involves more code about legalization.
>
> It should probably be a DAG combine and the transform that's turning (mul (add X, C1), C2) into (add (mul X, C2), C1 * C2) should ask the target if it is profitable, or at least call isLegalAddImmediate for C1*C2. @spatel or @lebedev.ri, what do you think?

Putting it into DAGCombine SGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107711/new/

https://reviews.llvm.org/D107711



More information about the llvm-commits mailing list