[PATCH] D83745: [ARM] Optimize immediate selection

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 07:13:16 PDT 2020


benshi001 added a comment.

1. Is there a benchmark test suite I can try?

2. If you think my change will be worse if there are multiple uses of the constant, then the same thing will happen for plus constant matches ARM_AM::isSOImmTwoPartVal. I think both positive and negative SOImmTwoPartVal constant  should be handled in the same way.

3. My change also benefits the following code:

%x=%y - 0x23ff23
previous llvm will generate  12 bytes:
ldr ...
sub ...
an item in the constant pool

but my change simplifies it to only 8 bytes:
sub %x, %y, 0x240000
add %x, %x, 0xdd
(I did not add a test case for that)

In D83745#2152988 <https://reviews.llvm.org/D83745#2152988>, @SjoerdMeijer wrote:

> I am not entirely sure anymore, but I thought I had looked into once, or at least something similar. I think the problem here is that if the constant is used only once like in the test, it is a clear win, but has soon as there are multiple uses than it's not better and probably worse. Also, with only one use, the code-size difference is neutral, but that won't be the case with multiple uses. So, I guess this work needs benchmark numbers, unless other reviewers that I've added can immediately tell if this is good or bad.





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

https://reviews.llvm.org/D83745





More information about the llvm-commits mailing list