[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 03:24:16 PDT 2021


benshi001 added inline comments.


================
Comment at: llvm/test/CodeGen/RISCV/addimm-mulimm.ll:241
+; RV64IM-NEXT:    addi a1, zero, 73
+; RV64IM-NEXT:    mulw a0, a0, a1
 ; RV64IM-NEXT:    ret
----------------
This should not be a regression, since 8 bytes are saved, and the mulw should cost  no more than 3 cycles since 73 is a small integer, so does for 19/25/41/73/11/13...


================
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
----------------
This can be further optimized to

(SLLIW (SH1ADD a0, a0, a0), 6).

I will make another patch for this optimization.


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

https://reviews.llvm.org/D107711



More information about the llvm-commits mailing list