[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 1 02:45:33 PDT 2023
================
@@ -5587,11 +5587,17 @@ Instruction *InstCombinerImpl::foldICmpWithZextOrSext(ICmpInst &ICmp) {
return new ICmpInst(ICmp.getPredicate(), Builder.CreateOr(X, Y),
Constant::getNullValue(X->getType()));
+ // Treat "zext nneg" as "sext"
+ bool IsNonNeg0 = isa<PossiblyNonNegInst>(ICmp.getOperand(0));
+ bool IsNonNeg1 = isa<PossiblyNonNegInst>(ICmp.getOperand(1));
----------------
nikic wrote:
This only checks whether the instruction *can* have an nneg flag, not whether it has it. You need to check `isNonNeg()` for that.
https://github.com/llvm/llvm-project/pull/70845
More information about the llvm-commits
mailing list