[PATCH] D111034: [AArch64] Optimize add/sub with immediate

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 12 20:13:00 PDT 2021


benshi001 added a comment.

In D111034#3058640 <https://reviews.llvm.org/D111034#3058640>, @dmgreen wrote:

> In D111034#3058614 <https://reviews.llvm.org/D111034#3058614>, @benshi001 wrote:
>
>> In D111034#3058375 <https://reviews.llvm.org/D111034#3058375>, @dmgreen wrote:
>>
>>> Thanks. Code looks good to me.
>>>
>>> Are there test cases anywhere for having these adds in a loop? And for negative tests where we are out of range for the transform?
>>
>> We do not have such tests, I will add three more tests,
>>
>> 1. add/sub 0x1ffffff, which exceeds 0xffffff;
>> 2. add/sub 0xaaaa, which does not exceed 0xffffff, but can be composed to (add x, (mov y, 0xaaaa));
>> 3. add/sub 0xaaaaaa inside a loop and this split optimization is blocked.
>>
>> Do you think enough ?
>>
>> Thank you.
>
> Yeah that sounds good to me. Thanks. If you add those, this patch LGTM.

I have added three negative tests in addsub.ll, which work meet our expectation.

  define i32 @add_27962026(i32 %a) {
    %b = add i32 %a, 27962026
    ret i32 %b
  }
  
  define i32 @add_65534(i32 %a) {
    %b = add i32 %a, 65534
    ret i32 %b
  }
  
  declare i32 @foox(i32)
  define void @add_in_loop(i32 %0) {
    br label %2
  2:
    %3 = phi i32 [ %0, %1 ], [ %5, %2 ]
    %4 = add nsw i32 %3, 11184810
    %5 = tail call i32 @foox(i32 %4) #2
    br label %2
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111034



More information about the llvm-commits mailing list