[PATCH] D124419: [InstCombine] try to fold icmp with mismatched extended operands
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 25 15:28:26 PDT 2022
spatel added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:4724
+ if ((CastOp1->getOpcode() == Instruction::SExt &&
+ isKnownNonNegative(X, DL, 0, &AC, &ICmp, &DT)) ||
+ (CastOp1->getOpcode() == Instruction::ZExt &&
----------------
nikic wrote:
> Isn't the sext handling here redundant due to https://github.com/llvm/llvm-project/blob/76d1f5eaa87b3d1ae5f4c07114313350152c24f2/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L1506-L1508, which will canonicalize to zext?
No - we are checking if Op1 (right-side of the cmp) is sext, then is Op0 source (zext on left-side) non-negative. The next clause is checking if Op1 is zext, then is Op1 source non-negative.
I coded it this way because we didn't actually test that Op1 is zext or sext (it could be some other cast). I can change that or add a code comment to better explain.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124419/new/
https://reviews.llvm.org/D124419
More information about the llvm-commits
mailing list