diff --git a/include/llvm/Support/KnownBits.h b/include/llvm/Support/KnownBits.h index 2937fced601..51a1df05052 100644 --- a/include/llvm/Support/KnownBits.h +++ b/include/llvm/Support/KnownBits.h @@ -299,7 +299,7 @@ public: KnownBits RHS); /// Compute known bits resulting from multiplying LHS and RHS. - static KnownBits computeForMul(const KnownBits &LHS, const KnownBits &RHS); + static KnownBits mul(const KnownBits &LHS, const KnownBits &RHS); /// Compute known bits from sign-extended multiply-hi. static KnownBits mulhs(const KnownBits &LHS, const KnownBits &RHS); diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 88910598066..d61f5ac47c7 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -462,7 +462,7 @@ static void computeKnownBitsMul(const Value *Op0, const Value *Op1, bool NSW, } } - Known = KnownBits::computeForMul(Known, Known2); + Known = KnownBits::mul(Known, Known2); // Only make use of no-wrap flags if we failed to compute the sign bit // directly. This matters if the multiplication always overflows, in @@ -1350,7 +1350,7 @@ static void computeKnownBitsFromOperator(const Operator *I, ScalingFactor = KnownBits::makeConstant(APInt(IndexBitWidth, TypeSizeInBytes)); } - IndexBits = KnownBits::computeForMul(IndexBits, ScalingFactor); + IndexBits = KnownBits::mul(IndexBits, ScalingFactor); // If the offsets have a different width from the pointer, according // to the language reference we need to sign-extend or truncate them diff --git a/lib/CodeGen/GlobalISel/GISelKnownBits.cpp b/lib/CodeGen/GlobalISel/GISelKnownBits.cpp index 2d02917552b..c4364abcc4d 100644 --- a/lib/CodeGen/GlobalISel/GISelKnownBits.cpp +++ b/lib/CodeGen/GlobalISel/GISelKnownBits.cpp @@ -302,7 +302,7 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known, Depth + 1); computeKnownBitsImpl(MI.getOperand(1).getReg(), Known2, DemandedElts, Depth + 1); - Known = KnownBits::computeForMul(Known, Known2); + Known = KnownBits::mul(Known, Known2); break; } case TargetOpcode::G_SELECT: { diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 1e46a4066b6..cfe0340198a 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2991,7 +2991,7 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts, case ISD::MUL: { Known = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1); Known2 = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1); - Known = KnownBits::computeForMul(Known, Known2); + Known = KnownBits::mul(Known, Known2); break; } case ISD::MULHU: { @@ -3011,7 +3011,7 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts, Known = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1); Known2 = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1); if (Op.getResNo() == 0) - Known = KnownBits::computeForMul(Known, Known2); + Known = KnownBits::mul(Known, Known2); else Known = KnownBits::mulhu(Known, Known2); break; @@ -3021,7 +3021,7 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts, Known = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1); Known2 = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1); if (Op.getResNo() == 0) - Known = KnownBits::computeForMul(Known, Known2); + Known = KnownBits::mul(Known, Known2); else Known = KnownBits::mulhs(Known, Known2); break; diff --git a/lib/Support/KnownBits.cpp b/lib/Support/KnownBits.cpp index 5da4cf7045f..d997bd85f1e 100644 --- a/lib/Support/KnownBits.cpp +++ b/lib/Support/KnownBits.cpp @@ -412,10 +412,11 @@ KnownBits KnownBits::abs(bool IntMinIsPoison) const { return KnownAbs; } -KnownBits KnownBits::computeForMul(const KnownBits &LHS, const KnownBits &RHS) { +KnownBits KnownBits::mul(const KnownBits &LHS, const KnownBits &RHS) { unsigned BitWidth = LHS.getBitWidth(); + assert(BitWidth == RHS.getBitWidth() && !LHS.hasConflict() && + !RHS.hasConflict() && "Operand mismatch"); - assert(!LHS.hasConflict() && !RHS.hasConflict()); // Compute a conservative estimate for high known-0 bits. unsigned LeadZ = std::max(LHS.countMinLeadingZeros() + RHS.countMinLeadingZeros(), @@ -497,7 +498,7 @@ KnownBits KnownBits::mulhs(const KnownBits &LHS, const KnownBits &RHS) { !RHS.hasConflict() && "Operand mismatch"); KnownBits WideLHS = LHS.sext(2 * BitWidth); KnownBits WideRHS = RHS.sext(2 * BitWidth); - return computeForMul(WideLHS, WideRHS).extractBits(BitWidth, BitWidth); + return mul(WideLHS, WideRHS).extractBits(BitWidth, BitWidth); } KnownBits KnownBits::mulhu(const KnownBits &LHS, const KnownBits &RHS) { @@ -506,7 +507,7 @@ KnownBits KnownBits::mulhu(const KnownBits &LHS, const KnownBits &RHS) { !RHS.hasConflict() && "Operand mismatch"); KnownBits WideLHS = LHS.zext(2 * BitWidth); KnownBits WideRHS = RHS.zext(2 * BitWidth); - return computeForMul(WideLHS, WideRHS).extractBits(BitWidth, BitWidth); + return mul(WideLHS, WideRHS).extractBits(BitWidth, BitWidth); } KnownBits KnownBits::udiv(const KnownBits &LHS, const KnownBits &RHS) { diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp index d9be8ab471a..17cace128ac 100644 --- a/lib/Target/ARM/ARMISelLowering.cpp +++ b/lib/Target/ARM/ARMISelLowering.cpp @@ -17785,7 +17785,7 @@ void ARMTargetLowering::computeKnownBitsForTargetNode(const SDValue Op, else if (Op.getOpcode() == ARMISD::CSINV) std::swap(KnownOp1.Zero, KnownOp1.One); else if (Op.getOpcode() == ARMISD::CSNEG) - KnownOp1 = KnownBits::computeForMul( + KnownOp1 = KnownBits::mul( KnownOp1, KnownBits::makeConstant(APInt(32, -1))); Known = KnownBits::commonBits(KnownOp0, KnownOp1); diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 3c81bc595eb..78ab73bfd16 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -34507,7 +34507,7 @@ void X86TargetLowering::computeKnownBitsForTargetNode(const SDValue Op, Known = Known.trunc(BitWidth / 2).zext(BitWidth); Known2 = Known2.trunc(BitWidth / 2).zext(BitWidth); - Known = KnownBits::computeForMul(Known, Known2); + Known = KnownBits::mul(Known, Known2); break; } case X86ISD::CMOV: { diff --git a/unittests/Support/KnownBitsTest.cpp b/unittests/Support/KnownBitsTest.cpp index 784bc6db70c..cce426748a6 100644 --- a/unittests/Support/KnownBitsTest.cpp +++ b/unittests/Support/KnownBitsTest.cpp @@ -230,7 +230,7 @@ TEST(KnownBitsTest, BinaryExhaustive) { // The following are conservatively correct, but not guaranteed to be // precise. - KnownBits ComputedMul = KnownBits::computeForMul(Known1, Known2); + KnownBits ComputedMul = KnownBits::mul(Known1, Known2); EXPECT_TRUE(ComputedMul.Zero.isSubsetOf(KnownMul.Zero)); EXPECT_TRUE(ComputedMul.One.isSubsetOf(KnownMul.One));