[llvm] r301656 - [APInt] Add clearSignBit method. Use it and setSignBit in a few places. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 28 09:58:06 PDT 2017
Author: ctopper
Date: Fri Apr 28 11:58:05 2017
New Revision: 301656
URL: http://llvm.org/viewvc/llvm-project?rev=301656&view=rev
Log:
[APInt] Add clearSignBit method. Use it and setSignBit in a few places. NFCI
Modified:
llvm/trunk/include/llvm/ADT/APInt.h
llvm/trunk/lib/Analysis/DemandedBits.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=301656&r1=301655&r2=301656&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Fri Apr 28 11:58:05 2017
@@ -1402,6 +1402,11 @@ public:
/// Set the given bit to 0 whose position is given as "bitPosition".
void clearBit(unsigned bitPosition);
+ /// Set the sign bit to 0.
+ void clearSignBit() {
+ clearBit(BitWidth - 1);
+ }
+
/// \brief Toggle every bit to its opposite value.
void flipAllBits() {
if (isSingleWord()) {
Modified: llvm/trunk/lib/Analysis/DemandedBits.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DemandedBits.cpp?rev=301656&r1=301655&r2=301656&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DemandedBits.cpp (original)
+++ llvm/trunk/lib/Analysis/DemandedBits.cpp Fri Apr 28 11:58:05 2017
@@ -181,7 +181,7 @@ void DemandedBits::determineLiveOperandB
// bits, then we must keep the highest input bit.
if ((AOut & APInt::getHighBitsSet(BitWidth, ShiftAmt))
.getBoolValue())
- AB.setBit(BitWidth-1);
+ AB.setSignBit();
// If the shift is exact, then the low bits are not dead
// (they must be zero).
@@ -239,7 +239,7 @@ void DemandedBits::determineLiveOperandB
if ((AOut & APInt::getHighBitsSet(AOut.getBitWidth(),
AOut.getBitWidth() - BitWidth))
.getBoolValue())
- AB.setBit(BitWidth-1);
+ AB.setSignBit();
break;
case Instruction::Select:
if (OperandNo != 0)
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=301656&r1=301655&r2=301656&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 28 11:58:05 2017
@@ -2719,7 +2719,7 @@ void SelectionDAG::computeKnownBits(SDVa
// We only know that the absolute values's MSB will be zero iff there is
// a set bit that isn't the sign bit (otherwise it could be INT_MIN).
- Known2.One.clearBit(BitWidth - 1);
+ Known2.One.clearSignBit();
if (Known2.One.getBoolValue()) {
Known.Zero = APInt::getSignMask(BitWidth);
break;
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=301656&r1=301655&r2=301656&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Fri Apr 28 11:58:05 2017
@@ -861,7 +861,7 @@ static bool checkRippleForAdd(const APIn
// Find the most significant known 0 other than the sign bit.
int BitWidth = Op0KnownZero.getBitWidth();
APInt Op0KnownZeroTemp(Op0KnownZero);
- Op0KnownZeroTemp.clearBit(BitWidth - 1);
+ Op0KnownZeroTemp.clearSignBit();
int Op0ZeroPosition = BitWidth - Op0KnownZeroTemp.countLeadingZeros() - 1;
int Op1OnePosition = BitWidth - Op1MaybeOne.countLeadingZeros() - 1;
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=301656&r1=301655&r2=301656&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Fri Apr 28 11:58:05 2017
@@ -190,8 +190,8 @@ static void computeSignedMinMaxValuesFro
Max = Known.One|UnknownBits;
if (UnknownBits.isNegative()) { // Sign bit is unknown
- Min.setBit(Min.getBitWidth()-1);
- Max.clearBit(Max.getBitWidth()-1);
+ Min.setSignBit();
+ Max.clearSignBit();
}
}
More information about the llvm-commits
mailing list