diff options
author | Dan Gohman <gohman@apple.com> | 2008-02-13 22:09:18 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-02-13 22:09:18 +0000 |
commit | 1ee8dc97d9898d446f7c018601d0f90081cbff6e (patch) | |
tree | 6ba1b8d7c039bf82609b6ba07e7053968d9a3b64 /llvm | |
parent | 22c3caab6ee56e418b75e2321ad06e54f92a5221 (diff) | |
download | bcm5719-llvm-1ee8dc97d9898d446f7c018601d0f90081cbff6e.tar.gz bcm5719-llvm-1ee8dc97d9898d446f7c018601d0f90081cbff6e.zip |
Rename APInt's isPositive to isNonNegative, to reflect what it
actually does.
llvm-svn: 47090
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 13 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 12 |
2 files changed, 13 insertions, 12 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 8fa1f950bc2..6d4b926cefa 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -232,16 +232,17 @@ public: } /// This tests the high bit of the APInt to determine if it is unset. - /// @brief Determine if this APInt Value is positive (not negative). - bool isPositive() const { + /// @brief Determine if this APInt Value is non-negative (>= 0) + bool isNonNegative() const { return !isNegative(); } - /// This tests if the value of this APInt is strictly positive (> 0). - /// @returns true if this APInt is Positive and not zero. - /// @brief Determine if this APInt Value is strictly positive. + /// This tests if the value of this APInt is positive (> 0). Note + /// that 0 is not a positive value. + /// @returns true if this APInt is positive. + /// @brief Determine if this APInt Value is positive. inline bool isStrictlyPositive() const { - return isPositive() && (*this) != 0; + return isNonNegative() && (*this) != 0; } /// This checks to see if the value has all bits of the APInt are set or not. diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 37c946223ed..c9ff01b9078 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -5293,12 +5293,12 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI, HiOverflow = LoOverflow = ProdOV; if (!HiOverflow) HiOverflow = AddWithOverflow(HiBound, LoBound, DivRHS, false); - } else if (DivRHS->getValue().isPositive()) { // Divisor is > 0. + } else if (DivRHS->getValue().isStrictlyPositive()) { // Divisor is > 0. if (CmpRHSV == 0) { // (X / pos) op 0 // Can't overflow. e.g. X/2 op 0 --> [-1, 2) LoBound = cast<ConstantInt>(ConstantExpr::getNeg(SubOne(DivRHS))); HiBound = DivRHS; - } else if (CmpRHSV.isPositive()) { // (X / pos) op pos + } else if (CmpRHSV.isStrictlyPositive()) { // (X / pos) op pos LoBound = Prod; // e.g. X/5 op 3 --> [15, 20) HiOverflow = LoOverflow = ProdOV; if (!HiOverflow) @@ -5311,7 +5311,7 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI, HiBound = AddOne(Prod); HiOverflow = ProdOV ? -1 : 0; } - } else { // Divisor is < 0. + } else if (DivRHS->getValue().isNegative()) { // Divisor is < 0. if (CmpRHSV == 0) { // (X / neg) op 0 // e.g. X/-5 op 0 --> [-4, 5) LoBound = AddOne(DivRHS); @@ -5320,7 +5320,7 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI, HiOverflow = 1; // [INTMIN+1, overflow) HiBound = 0; // e.g. X/INTMIN = 0 --> X > INTMIN } - } else if (CmpRHSV.isPositive()) { // (X / neg) op pos + } else if (CmpRHSV.isStrictlyPositive()) { // (X / neg) op pos // e.g. X/-5 op 3 --> [-19, -14) HiOverflow = LoOverflow = ProdOV ? -1 : 0; if (!LoOverflow) @@ -5434,8 +5434,8 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, // Extending a relational comparison when we're checking the sign // bit would not work. if (Cast->hasOneUse() && - (ICI.isEquality() || AndCST->getValue().isPositive() && - RHSV.isPositive())) { + (ICI.isEquality() || AndCST->getValue().isNonNegative() && + RHSV.isNonNegative())) { uint32_t BitWidth = cast<IntegerType>(Cast->getOperand(0)->getType())->getBitWidth(); APInt NewCST = AndCST->getValue(); |