[llvm] [KnownBits] Remove `hasConflict()` assertions (PR #94568)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 01:11:50 PDT 2024
https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/94568
>From 87a6753928eda38442bea5eaffe8f755f7c2a383 Mon Sep 17 00:00:00 2001
From: c8ef <c8ef at outlook.com>
Date: Thu, 6 Jun 2024 12:36:20 +0800
Subject: [PATCH 1/3] remove hasConflict() assertions
---
llvm/include/llvm/Support/KnownBits.h | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/llvm/include/llvm/Support/KnownBits.h b/llvm/include/llvm/Support/KnownBits.h
index ba4a5f01036c..c206bd77d588 100644
--- a/llvm/include/llvm/Support/KnownBits.h
+++ b/llvm/include/llvm/Support/KnownBits.h
@@ -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();
}
@@ -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() {
>From 98b33682838ee8b407457fc0de2f5563823720c0 Mon Sep 17 00:00:00 2001
From: c8ef <c8ef at outlook.com>
Date: Thu, 6 Jun 2024 16:06:21 +0800
Subject: [PATCH 2/3] remove more assert
---
llvm/lib/Analysis/ValueTracking.cpp | 1 -
.../lib/CodeGen/GlobalISel/GISelKnownBits.cpp | 1 -
.../lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 1 -
.../CodeGen/SelectionDAG/TargetLowering.cpp | 22 +-----------------
llvm/lib/IR/ConstantRange.cpp | 2 --
llvm/lib/Support/KnownBits.cpp | 23 +++----------------
llvm/lib/Target/X86/X86ISelLowering.cpp | 5 ----
.../InstCombineSimplifyDemanded.cpp | 21 ++---------------
8 files changed, 6 insertions(+), 70 deletions(-)
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 08138a5e2f2d..357a5917c725 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1158,7 +1158,6 @@ static void computeKnownBitsFromOperator(const Operator *I,
Known.makeNonNegative();
}
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
break;
}
diff --git a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
index 32d607cfd71a..2988fa45b2e3 100644
--- a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
@@ -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.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 09cdec8adb27..ef87882591f1 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -4212,7 +4212,6 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
break;
}
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
return Known;
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index f856c8a51984..1867b22f60f0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -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'.
@@ -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()) {
@@ -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'.
@@ -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'.
@@ -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))
@@ -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);
@@ -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))
@@ -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.
@@ -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.
@@ -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);
@@ -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.
@@ -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);
@@ -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.
@@ -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);
@@ -2620,7 +2602,6 @@ bool TargetLowering::SimplifyDemandedBits(
break;
}
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
break;
}
case ISD::AssertZext: {
@@ -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);
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index c3bde48b982c..76ea26b753d1 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -58,8 +58,6 @@ ConstantRange::ConstantRange(APInt L, APInt U)
ConstantRange ConstantRange::fromKnownBits(const KnownBits &Known,
bool IsSigned) {
- assert(!Known.hasConflict() && "Expected valid KnownBits");
-
if (Known.isUnknown())
return getFull(Known.getBitWidth());
diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp
index d6012a8eea8a..0f99e6c58b87 100644
--- a/llvm/lib/Support/KnownBits.cpp
+++ b/llvm/lib/Support/KnownBits.cpp
@@ -608,14 +608,12 @@ KnownBits KnownBits::abs(bool IntMinIsPoison) const {
}
}
- assert(!KnownAbs.hasConflict() && "Bad Output");
return KnownAbs;
}
static KnownBits computeForSatAddSub(bool Add, bool Signed,
const KnownBits &LHS,
const KnownBits &RHS) {
- assert(!LHS.hasConflict() && !RHS.hasConflict() && "Bad inputs");
// We don't see NSW even for sadd/ssub as we want to check if the result has
// signed overflow.
KnownBits Res =
@@ -715,7 +713,6 @@ static KnownBits computeForSatAddSub(bool Add, bool Signed,
// We know whether or not we overflowed.
if (!(*Overflow)) {
// No overflow.
- assert(!Res.hasConflict() && "Bad Output");
return Res;
}
@@ -737,7 +734,6 @@ static KnownBits computeForSatAddSub(bool Add, bool Signed,
Res.One = C;
Res.Zero = ~C;
- assert(!Res.hasConflict() && "Bad Output");
return Res;
}
@@ -757,7 +753,6 @@ static KnownBits computeForSatAddSub(bool Add, bool Signed,
Res.One.clearAllBits();
}
- assert(!Res.hasConflict() && "Bad Output");
return Res;
}
@@ -808,8 +803,7 @@ KnownBits KnownBits::avgCeilU(const KnownBits &LHS, const KnownBits &RHS) {
KnownBits KnownBits::mul(const KnownBits &LHS, const KnownBits &RHS,
bool NoUndefSelfMultiply) {
unsigned BitWidth = LHS.getBitWidth();
- assert(BitWidth == RHS.getBitWidth() && !LHS.hasConflict() &&
- !RHS.hasConflict() && "Operand mismatch");
+ assert(BitWidth == RHS.getBitWidth() && "Operand mismatch");
assert((!NoUndefSelfMultiply || LHS == RHS) &&
"Self multiplication knownbits mismatch");
@@ -905,8 +899,7 @@ KnownBits KnownBits::mul(const KnownBits &LHS, const KnownBits &RHS,
KnownBits KnownBits::mulhs(const KnownBits &LHS, const KnownBits &RHS) {
unsigned BitWidth = LHS.getBitWidth();
- assert(BitWidth == RHS.getBitWidth() && !LHS.hasConflict() &&
- !RHS.hasConflict() && "Operand mismatch");
+ assert(BitWidth == RHS.getBitWidth() && "Operand mismatch");
KnownBits WideLHS = LHS.sext(2 * BitWidth);
KnownBits WideRHS = RHS.sext(2 * BitWidth);
return mul(WideLHS, WideRHS).extractBits(BitWidth, BitWidth);
@@ -914,8 +907,7 @@ KnownBits KnownBits::mulhs(const KnownBits &LHS, const KnownBits &RHS) {
KnownBits KnownBits::mulhu(const KnownBits &LHS, const KnownBits &RHS) {
unsigned BitWidth = LHS.getBitWidth();
- assert(BitWidth == RHS.getBitWidth() && !LHS.hasConflict() &&
- !RHS.hasConflict() && "Operand mismatch");
+ assert(BitWidth == RHS.getBitWidth() && "Operand mismatch");
KnownBits WideLHS = LHS.zext(2 * BitWidth);
KnownBits WideRHS = RHS.zext(2 * BitWidth);
return mul(WideLHS, WideRHS).extractBits(BitWidth, BitWidth);
@@ -964,7 +956,6 @@ KnownBits KnownBits::sdiv(const KnownBits &LHS, const KnownBits &RHS,
return udiv(LHS, RHS, Exact);
unsigned BitWidth = LHS.getBitWidth();
- assert(!LHS.hasConflict() && !RHS.hasConflict() && "Bad inputs");
KnownBits Known(BitWidth);
if (LHS.isZero() || RHS.isZero()) {
@@ -1011,15 +1002,12 @@ KnownBits KnownBits::sdiv(const KnownBits &LHS, const KnownBits &RHS,
}
Known = divComputeLowBit(Known, LHS, RHS, Exact);
-
- assert(!Known.hasConflict() && "Bad Output");
return Known;
}
KnownBits KnownBits::udiv(const KnownBits &LHS, const KnownBits &RHS,
bool Exact) {
unsigned BitWidth = LHS.getBitWidth();
- assert(!LHS.hasConflict() && !RHS.hasConflict());
KnownBits Known(BitWidth);
if (LHS.isZero() || RHS.isZero()) {
@@ -1041,7 +1029,6 @@ KnownBits KnownBits::udiv(const KnownBits &LHS, const KnownBits &RHS,
Known.Zero.setHighBits(LeadZ);
Known = divComputeLowBit(Known, LHS, RHS, Exact);
- assert(!Known.hasConflict() && "Bad Output");
return Known;
}
@@ -1059,8 +1046,6 @@ KnownBits KnownBits::remGetLowBits(const KnownBits &LHS, const KnownBits &RHS) {
}
KnownBits KnownBits::urem(const KnownBits &LHS, const KnownBits &RHS) {
- assert(!LHS.hasConflict() && !RHS.hasConflict());
-
KnownBits Known = remGetLowBits(LHS, RHS);
if (RHS.isConstant() && RHS.getConstant().isPowerOf2()) {
// NB: Low bits set in `remGetLowBits`.
@@ -1078,8 +1063,6 @@ KnownBits KnownBits::urem(const KnownBits &LHS, const KnownBits &RHS) {
}
KnownBits KnownBits::srem(const KnownBits &LHS, const KnownBits &RHS) {
- assert(!LHS.hasConflict() && !RHS.hasConflict());
-
KnownBits Known = remGetLowBits(LHS, RHS);
if (RHS.isConstant() && RHS.getConstant().isPowerOf2()) {
// NB: Low bits are set in `remGetLowBits`.
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index af1e45d25aac..0882ea3fdaca 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -42445,12 +42445,10 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode(
if (SimplifyDemandedBits(Op1, OriginalDemandedBits, OriginalDemandedElts,
Known, TLO, Depth + 1))
return true;
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
if (SimplifyDemandedBits(Op0, ~Known.Zero & OriginalDemandedBits,
OriginalDemandedElts, Known2, TLO, Depth + 1))
return true;
- assert(!Known2.hasConflict() && "Bits known to be one AND zero?");
// If the RHS is a constant, see if we can simplify it.
if (ShrinkDemandedConstant(Op, ~Known2.One & OriginalDemandedBits,
@@ -42501,7 +42499,6 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode(
TLO, Depth + 1))
return true;
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
Known.Zero <<= ShAmt;
Known.One <<= ShAmt;
@@ -42520,7 +42517,6 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode(
OriginalDemandedElts, Known, TLO, Depth + 1))
return true;
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
Known.Zero.lshrInPlace(ShAmt);
Known.One.lshrInPlace(ShAmt);
@@ -42561,7 +42557,6 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode(
TLO, Depth + 1))
return true;
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
Known.Zero.lshrInPlace(ShAmt);
Known.One.lshrInPlace(ShAmt);
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 6739b8745d74..e538d78d908c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -209,8 +209,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
SimplifyDemandedBits(I, 0, DemandedMask & ~RHSKnown.Zero, LHSKnown,
Depth + 1))
return I;
- assert(!RHSKnown.hasConflict() && "Bits known to be one AND zero?");
- assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?");
Known = analyzeKnownBitsFromAndXorOr(cast<Operator>(I), LHSKnown, RHSKnown,
Depth, SQ.getWithInstruction(CxtI));
@@ -242,8 +240,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
I->dropPoisonGeneratingFlags();
return I;
}
- assert(!RHSKnown.hasConflict() && "Bits known to be one AND zero?");
- assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?");
Known = analyzeKnownBitsFromAndXorOr(cast<Operator>(I), LHSKnown, RHSKnown,
Depth, SQ.getWithInstruction(CxtI));
@@ -291,9 +287,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
return Builder.CreateUnaryIntrinsic(Intrinsic::ctpop, Xor);
}
- assert(!RHSKnown.hasConflict() && "Bits known to be one AND zero?");
- assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?");
-
Known = analyzeKnownBitsFromAndXorOr(cast<Operator>(I), LHSKnown, RHSKnown,
Depth, SQ.getWithInstruction(CxtI));
@@ -375,8 +368,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
if (SimplifyDemandedBits(I, 2, DemandedMask, RHSKnown, Depth + 1) ||
SimplifyDemandedBits(I, 1, DemandedMask, LHSKnown, Depth + 1))
return I;
- assert(!RHSKnown.hasConflict() && "Bits known to be one AND zero?");
- assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?");
// If the operands are constants, see if we can simplify them.
// This is similar to ShrinkDemandedConstant, but for a select we want to
@@ -455,7 +446,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
InputKnown.makeNonNegative();
Known = InputKnown.zextOrTrunc(BitWidth);
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
break;
}
case Instruction::SExt: {
@@ -485,9 +475,8 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
// If the sign bit of the input is known set or clear, then we know the
// top bits of the result.
- Known = InputKnown.sext(BitWidth);
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
- break;
+ Known = InputKnown.sext(BitWidth);
+ break;
}
case Instruction::Add: {
if ((DemandedMask & 1) == 0) {
@@ -696,7 +685,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
if (SimplifyDemandedBits(I, 0, DemandedMaskIn, Known, Depth + 1))
return I;
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
Known = KnownBits::shl(Known,
KnownBits::makeConstant(APInt(BitWidth, ShiftAmt)),
@@ -772,7 +760,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
I->dropPoisonGeneratingFlags();
return I;
}
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
Known.Zero.lshrInPlace(ShiftAmt);
Known.One.lshrInPlace(ShiftAmt);
if (ShiftAmt)
@@ -819,7 +806,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
return I;
}
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
// Compute the new bits that are at the top now plus sign bits.
APInt HighBits(APInt::getHighBitsSet(
BitWidth, std::min(SignBits + ShiftAmt - 1, BitWidth)));
@@ -900,7 +886,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
if (LHSKnown.isNegative() && LowBits.intersects(LHSKnown.One))
Known.One |= ~LowBits;
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
break;
}
}
@@ -978,8 +963,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
// TODO: Should be 1-extend
RHSKnown = RHSKnown.anyextOrTrunc(BitWidth);
- assert(!RHSKnown.hasConflict() && "Bits known to be one AND zero?");
- assert(!LHSKnown.hasConflict() && "Bits known to be one AND zero?");
Known = LHSKnown & RHSKnown;
KnownBitsComputed = true;
>From 5878f2421c3d313758e50389f4854d26c7f4867c Mon Sep 17 00:00:00 2001
From: c8ef <c8ef at outlook.com>
Date: Thu, 6 Jun 2024 16:11:35 +0800
Subject: [PATCH 3/3] clang-format
---
.../Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index e538d78d908c..b3eebee0d0d8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -471,12 +471,12 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
CastInst *NewCast = new ZExtInst(I->getOperand(0), VTy);
NewCast->takeName(I);
return InsertNewInstWith(NewCast, I->getIterator());
- }
+ }
// If the sign bit of the input is known set or clear, then we know the
// top bits of the result.
- Known = InputKnown.sext(BitWidth);
- break;
+ Known = InputKnown.sext(BitWidth);
+ break;
}
case Instruction::Add: {
if ((DemandedMask & 1) == 0) {
More information about the llvm-commits
mailing list