[llvm] [AArch64] Extend condition optimizer to support unsigned comparisons (PR #144380)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 23 16:46:07 PDT 2025


AZero13 wrote:

So, basically everything was tested. Which is why I made sure to ensure that all cases were covered.

For example: x > 0 || x < -1, does not work when unsigned, so how do I check this? by checking that we switched from adds to subs. 

I used a helper function to check between both signed and unsigned variants, and the realheadimm was because it is important to know what we are truly comparing again.

Now, it is not obvious how this actually relates to https://github.com/llvm/llvm-project/pull/143013. 

That is my fault, but honestly, fixing the root cause of one of the issues responsible for that is required to get this to work too.

How? Well, look at adjustCmp. It was flipping the sign at cmn 0 to cmp 1, when it should have been cmp 0. And therefore, the logic was flawed to begin with. And this is important as when we do a signed wrap, we change from subs to adds, etc.

https://github.com/llvm/llvm-project/pull/144380


More information about the llvm-commits mailing list