Skip to content
Merged
11 changes: 2 additions & 9 deletions llvm/include/llvm/Support/KnownBits.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct KnownBits {

/// Returns true if we know the value of all bits.
bool isConstant() const {
assert(!hasConflict() && "KnownBits conflict!");
return Zero.popcount() + One.popcount() == getBitWidth();
}

Expand All @@ -74,16 +73,10 @@ struct KnownBits {
}

/// Returns true if value is all zero.
bool isZero() const {
assert(!hasConflict() && "KnownBits conflict!");
return Zero.isAllOnes();
}
bool isZero() const { return Zero.isAllOnes(); }

/// Returns true if value is all one bits.
bool isAllOnes() const {
assert(!hasConflict() && "KnownBits conflict!");
return One.isAllOnes();
}
bool isAllOnes() const { return One.isAllOnes(); }

/// Make all bits known to be zero and discard any previous information.
void setAllZero() {
Expand Down
3 changes: 0 additions & 3 deletions llvm/lib/Analysis/ValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,6 @@ static void computeKnownBitsFromOperator(const Operator *I,
Known.makeNonNegative();
}

assert(!Known.hasConflict() && "Bits known to be one AND zero?");
break;
}

Expand Down Expand Up @@ -2055,8 +2054,6 @@ void computeKnownBits(const Value *V, const APInt &DemandedElts,

// Check whether we can determine known bits from context such as assumes.
computeKnownBitsFromContext(V, Known, Depth, Q);

assert((Known.Zero & Known.One) == 0 && "Bits known to be one AND zero?");
}

/// Try to detect a recurrence that the value of the induction variable is
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known,
}
}

assert(!Known.hasConflict() && "Bits known to be one AND zero?");
LLVM_DEBUG(dumpResult(MI, Known, Depth));

// Update the cache.
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4212,7 +4212,6 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
break;
}

assert(!Known.hasConflict() && "Bits known to be one AND zero?");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just focus on the middle-end initially and then look at removing the DAG/GlobalISel assertions later?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it's safer to get rid of it everyone at once.

return Known;
}

Expand Down
22 changes: 1 addition & 21 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,11 +1436,9 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Op1, DemandedBits, DemandedElts, Known, TLO,
Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
if (SimplifyDemandedBits(Op0, ~Known.Zero & DemandedBits, DemandedElts,
Known2, TLO, Depth + 1))
return true;
assert(!Known2.hasConflict() && "Bits known to be one AND zero?");

// If all of the demanded bits are known one on one side, return the other.
// These bits cannot contribute to the result of the 'and'.
Expand Down Expand Up @@ -1488,7 +1486,7 @@ bool TargetLowering::SimplifyDemandedBits(
}
return true;
}
assert(!Known.hasConflict() && "Bits known to be one AND zero?");

if (SimplifyDemandedBits(Op0, ~Known.One & DemandedBits, DemandedElts,
Known2, TLO, Depth + 1)) {
if (Flags.hasDisjoint()) {
Expand All @@ -1497,7 +1495,6 @@ bool TargetLowering::SimplifyDemandedBits(
}
return true;
}
assert(!Known2.hasConflict() && "Bits known to be one AND zero?");

// If all of the demanded bits are known zero on one side, return the other.
// These bits cannot contribute to the result of the 'or'.
Expand Down Expand Up @@ -1563,11 +1560,9 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Op1, DemandedBits, DemandedElts, Known, TLO,
Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
if (SimplifyDemandedBits(Op0, DemandedBits, DemandedElts, Known2, TLO,
Depth + 1))
return true;
assert(!Known2.hasConflict() && "Bits known to be one AND zero?");

// If all of the demanded bits are known zero on one side, return the other.
// These bits cannot contribute to the result of the 'xor'.
Expand Down Expand Up @@ -1663,8 +1658,6 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Op.getOperand(1), DemandedBits, DemandedElts,
Known2, TLO, Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
assert(!Known2.hasConflict() && "Bits known to be one AND zero?");

// If the operands are constants, see if we can simplify them.
if (ShrinkDemandedConstant(Op, DemandedBits, DemandedElts, TLO))
Expand All @@ -1680,8 +1673,6 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Op.getOperand(1), DemandedBits, DemandedElts,
Known2, TLO, Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
assert(!Known2.hasConflict() && "Bits known to be one AND zero?");

// Only known if known in both the LHS and RHS.
Known = Known.intersectWith(Known2);
Expand All @@ -1693,8 +1684,6 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Op.getOperand(2), DemandedBits, DemandedElts,
Known2, TLO, Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
assert(!Known2.hasConflict() && "Bits known to be one AND zero?");

// If the operands are constants, see if we can simplify them.
if (ShrinkDemandedConstant(Op, DemandedBits, DemandedElts, TLO))
Expand Down Expand Up @@ -1819,7 +1808,6 @@ bool TargetLowering::SimplifyDemandedBits(
}
return true;
}
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
Known.Zero <<= ShAmt;
Known.One <<= ShAmt;
// low bits known zero.
Expand Down Expand Up @@ -1993,7 +1981,6 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Op0, InDemandedMask, DemandedElts, Known, TLO,
Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
Known.Zero.lshrInPlace(ShAmt);
Known.One.lshrInPlace(ShAmt);
// High bits known zero.
Expand Down Expand Up @@ -2090,7 +2077,6 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Op0, InDemandedMask, DemandedElts, Known, TLO,
Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
Known.Zero.lshrInPlace(ShAmt);
Known.One.lshrInPlace(ShAmt);

Expand Down Expand Up @@ -2385,7 +2371,6 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Op0, InputDemandedBits, DemandedElts, Known, TLO,
Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");

// If the sign bit of the input is known set or clear, then we know the
// top bits of the result.
Expand Down Expand Up @@ -2458,7 +2443,6 @@ bool TargetLowering::SimplifyDemandedBits(
}
return true;
}
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
assert(Known.getBitWidth() == InBits && "Src width has changed?");
Known = Known.zext(BitWidth);

Expand Down Expand Up @@ -2508,7 +2492,6 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Src, InDemandedBits, InDemandedElts, Known, TLO,
Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
assert(Known.getBitWidth() == InBits && "Src width has changed?");

// If the sign bit is known one, the top bits match.
Expand Down Expand Up @@ -2554,7 +2537,6 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Src, InDemandedBits, InDemandedElts, Known, TLO,
Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
assert(Known.getBitWidth() == InBits && "Src width has changed?");
Known = Known.anyext(BitWidth);

Expand Down Expand Up @@ -2620,7 +2602,6 @@ bool TargetLowering::SimplifyDemandedBits(
break;
}

assert(!Known.hasConflict() && "Bits known to be one AND zero?");
break;
}
case ISD::AssertZext: {
Expand All @@ -2631,7 +2612,6 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Op.getOperand(0), ~InMask | DemandedBits, Known,
TLO, Depth + 1))
return true;
assert(!Known.hasConflict() && "Bits known to be one AND zero?");

Known.Zero |= ~InMask;
Known.One &= (~Known.Zero);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/IR/ConstantRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ ConstantRange::ConstantRange(APInt L, APInt U)

ConstantRange ConstantRange::fromKnownBits(const KnownBits &Known,
bool IsSigned) {
assert(!Known.hasConflict() && "Expected valid KnownBits");

if (Known.hasConflict())
return getEmpty(Known.getBitWidth());
if (Known.isUnknown())
return getFull(Known.getBitWidth());

Expand Down
Loading