Skip to content

Commit 6b044c0

Browse files
committed
Drop isKnownNonNegative() call
1 parent 77476a6 commit 6b044c0

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5554,20 +5554,16 @@ Instruction *InstCombinerImpl::foldICmpWithZextOrSext(ICmpInst &ICmp) {
55545554
return new ICmpInst(ICmp.getPredicate(), Builder.CreateOr(X, Y),
55555555
Constant::getNullValue(X->getType()));
55565556

5557-
// Treat "zext nneg" as "sext"
5557+
// If we have mismatched casts and zext has the nneg flag, we can
5558+
// treat the "zext nneg" as "sext". Otherwise, we cannot fold and quit.
5559+
55585560
auto *NonNegInst0 = dyn_cast<PossiblyNonNegInst>(ICmp.getOperand(0));
55595561
auto *NonNegInst1 = dyn_cast<PossiblyNonNegInst>(ICmp.getOperand(1));
55605562

55615563
bool IsNonNeg0 = NonNegInst0 && NonNegInst0->hasNonNeg();
55625564
bool IsNonNeg1 = NonNegInst1 && NonNegInst1->hasNonNeg();
55635565

5564-
// If we have mismatched casts, treat the zext of a non-negative source as
5565-
// a sext to simulate matching casts. Otherwise, we are done.
5566-
// TODO: Can we handle some predicates (equality) without non-negative?
5567-
if ((IsZext0 &&
5568-
(IsNonNeg0 || isKnownNonNegative(X, DL, 0, &AC, &ICmp, &DT))) ||
5569-
(IsZext1 &&
5570-
(IsNonNeg1 || isKnownNonNegative(Y, DL, 0, &AC, &ICmp, &DT))))
5566+
if ((IsZext0 && IsNonNeg0) || (IsZext1 && IsNonNeg1))
55715567
IsSignedExt = true;
55725568
else
55735569
return nullptr;

0 commit comments

Comments
 (0)