diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-19 20:58:18 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-19 20:58:18 +0000 |
commit | 450434ed659bcc548a3ac01e8fa40786fa722154 (patch) | |
tree | f6f927a0809b9eb8d463835388099b9e3d625508 /llvm/lib/Transforms | |
parent | 03c31d5bb0af5db22c94097a06c0f3a06a3bda9d (diff) | |
download | bcm5719-llvm-450434ed659bcc548a3ac01e8fa40786fa722154.tar.gz bcm5719-llvm-450434ed659bcc548a3ac01e8fa40786fa722154.zip |
1. Use APInt::getSignBit to reduce clutter (patch by Sheng Zhou)
2. Replace uses of the "isPositive" utility function with APInt::isPositive
llvm-svn: 35185
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 38b05b5029e..e38622a569f 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2760,7 +2760,7 @@ FoundSExt: // highest order bit set. static bool isSignBit(ConstantInt *CI) { unsigned NumBits = CI->getType()->getPrimitiveSizeInBits(); - return (CI->getZExtValue() & (~0ULL >> (64-NumBits))) == (1ULL << (NumBits-1)); + return CI->getValue() == APInt::getSignBit(NumBits); } Instruction *InstCombiner::visitSub(BinaryOperator &I) { @@ -4925,10 +4925,6 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { return Changed ? &I : 0; } -static bool isPositive(ConstantInt *C) { - return C->getSExtValue() >= 0; -} - /// AddWithOverflow - Compute Result = In1+In2, returning true if the result /// overflowed for this type. static bool AddWithOverflow(ConstantInt *&Result, ConstantInt *In1, @@ -5707,12 +5703,12 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { LoBound = Prod; LoOverflow = ProdOV; HiOverflow = ProdOV || AddWithOverflow(HiBound, LoBound, DivRHS); - } else if (isPositive(DivRHS)) { // Divisor is > 0. + } else if (DivRHS->getValue().isPositive()) { // Divisor is > 0. if (CI->isNullValue()) { // (X / pos) op 0 // Can't overflow. LoBound = cast<ConstantInt>(ConstantExpr::getNeg(SubOne(DivRHS))); HiBound = DivRHS; - } else if (isPositive(CI)) { // (X / pos) op pos + } else if (CI->getValue().isPositive()) { // (X / pos) op pos LoBound = Prod; LoOverflow = ProdOV; HiOverflow = ProdOV || AddWithOverflow(HiBound, Prod, DivRHS); @@ -5729,7 +5725,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { HiBound = cast<ConstantInt>(ConstantExpr::getNeg(DivRHS)); if (HiBound == DivRHS) LoBound = 0; // - INTMIN = INTMIN - } else if (isPositive(CI)) { // (X / neg) op pos + } else if (CI->getValue().isPositive()) { // (X / neg) op pos HiOverflow = LoOverflow = ProdOV; if (!LoOverflow) LoOverflow = AddWithOverflow(LoBound, Prod, AddOne(DivRHS)); |