[llvm] [CVP] #114820 add 'samesign' for 'icmp' (PR #115642)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 10 01:22:25 PST 2024
================
@@ -288,24 +288,36 @@ static bool processICmp(ICmpInst *Cmp, LazyValueInfo *LVI) {
if (!Cmp->getOperand(0)->getType()->isIntOrIntVectorTy())
return false;
- if (!Cmp->isSigned())
+ if (!(Cmp->isSigned() || (Cmp->isUnsigned() && !Cmp->hasSameSign())))
return false;
- ICmpInst::Predicate UnsignedPred =
- ConstantRange::getEquivalentPredWithFlippedSignedness(
- Cmp->getPredicate(),
- LVI->getConstantRangeAtUse(Cmp->getOperandUse(0),
- /*UndefAllowed*/ true),
- LVI->getConstantRangeAtUse(Cmp->getOperandUse(1),
- /*UndefAllowed*/ true));
+ bool Changed = false;
- if (UnsignedPred == ICmpInst::Predicate::BAD_ICMP_PREDICATE)
- return false;
+ ConstantRange CR1 = LVI->getConstantRangeAtUse(Cmp->getOperandUse(0),
+ /*UndefAllowed=*/ true),
+ CR2 = LVI->getConstantRangeAtUse(Cmp->getOperandUse(1),
+ /*UndefAllowed=*/ true);
----------------
nikic wrote:
I don't think that UndefAllowed=true is correct for this optimization. We should set UndefAllowed=false.
https://github.com/llvm/llvm-project/pull/115642
More information about the llvm-commits
mailing list