[PATCH] D110867: X86InstrInfo: Support immediates that are +1/-1 different in optimizeCompareInstr
Matthias Braun via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 15 11:02:48 PDT 2021
MatzeB added inline comments.
================
Comment at: llvm/lib/Target/X86/X86InstrInfo.cpp:4495
+ case X86::COND_L: // x <s (C + 1) --> x <=s C
+ if (ImmDelta != 1 || APInt(BitWidth, INT64_MIN) == CmpValue)
+ return false;
----------------
foad wrote:
> Surely you need `APInt::getSignedMinValue(BitWidth)`?
Good point. Changed them now.
I just realized that technically this check isn't necessary as the tests I added still pass. This is because the `ImmDelta` calculations are actually done on `int64_t` values so they don't wrap around for 8/16/32 bit immediates and instead just overflow to an unrepresentable immediate. We would have overflow problems for 64bit immediates, but x86 doesn't support those.
Anyway I think I'll keep the tests here anyway as I like the expressed intent, and if someone ever introduces a 64bit immediates we are prepared :)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110867/new/
https://reviews.llvm.org/D110867
More information about the llvm-commits
mailing list