[PATCH] D107711: [DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 10 05:28:01 PDT 2021


benshi001 added inline comments.


================
Comment at: llvm/test/CodeGen/RISCV/addimm-mulimm.ll:305
+; RV64IM-NEXT:    addi a1, zero, 192
+; RV64IM-NEXT:    mulw a0, a0, a1
 ; RV64IM-NEXT:    ret
----------------
benshi001 wrote:
> benshi001 wrote:
> > This can be further optimized to
> > 
> > (SLLIW (SH1ADD a0, a0, a0), 6).
> > 
> > I will make another patch for this optimization.
> The best form should be
> 
> ; RV64IM-NEXT:    addi a0, a0, 1000
> ; RV64IM-NEXT:    sh1add a0, a0, a0
> ; RV64IM-NEXT:    slliw a0, a0, 6
> 
> It can be done via new rules in RISCVInstrInfoB.td
I have submitted another patch to optimize that case.

https://reviews.llvm.org/D107820


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

https://reviews.llvm.org/D107711



More information about the llvm-commits mailing list