[PATCH] D147305: [LoongArch] Optimize multiplication with immediates

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 1 22:10:10 PDT 2023


benshi001 added a comment.

In D147305#4238054 <https://reviews.llvm.org/D147305#4238054>, @xen0n wrote:

> In D147305#4237973 <https://reviews.llvm.org/D147305#4237973>, @benshi001 wrote:
>
>> In D147305#4237944 <https://reviews.llvm.org/D147305#4237944>, @SixWeining wrote:
>>
>>> Thanks for the improvements.
>>> So this is only for the `case 2` mentioned by @xen0n, right? Seems that the test for `81` is missing.
>>>
>>> Will `case 1` and `case 3` be handled later?
>>
>> Thanks for your comments.
>>
>> 1. The missing case 81 is added.
>> 2. I will implement `case 1` and `case 3` later in another patch. BTW: Total amount of these two cases is small, and they even have redundant values with `case 2`, so how about implementing them without `foreach`, just standalone `Pat` one by one ?
>
> As for point 2, fine by me. Case 1 would still have many remaining constants so a macro would go a long way (you could only go over the distinct Imm1 and Imm2 and auto-compute the source constant as you did for Case 2), and only 33 would be left for Case 3 so you may write the pattern straight-forward.

Unfortanately the `case 3` you mentioned can not be implemented, besides other duplicates to `case 2`, the remaining immediate `x * 33` will be optimized to `(x << 5) + x`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147305



More information about the llvm-commits mailing list