[PATCH] D105796: [RISCV] Optimize multiplication in the zba extension with SH*ADD

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 16 20:49:48 PDT 2021


craig.topper added a comment.

In D105796#2885104 <https://reviews.llvm.org/D105796#2885104>, @benshi001 wrote:

> I change the $rs2 in the Pat from non_imm12 to GPR as following
>
>   def : Pat<(addshl GPR:$rs1, (XLenVT 1), (XLenVT 2), GPR:$rs2),
>             (SH1ADD (SH1ADD GPR:$rs1, GPR:$rs1), GPR:$rs2)>;
>
> Because for `a*6 + 10`, `non_imm12:$rs2` will lead to
>
>   addi Rb, zero, 6
>   mul Ra, Rb, Ra
>   addi Ra, Ra, 6
>
> while `GPR:$rs2` will lead to
>
>   addi Rb, zero, 10
>   sh1add Ra, Ra, Ra
>   sh1add Ra, Ra, Rb
>
> And I think the later one is better, so I changed `non_imm12:$rs2` to `GPR:$rs2`.

I'm not sure I follow this. How can a change to the isel pattern cause a mul to be created? Wasn't the mul already decomposed?


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

https://reviews.llvm.org/D105796



More information about the llvm-commits mailing list