[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Reid Spencer reid at x10sys.com
Mon Mar 19 14:10:46 PDT 2007



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.666 -> 1.667
---
Log message:

Implement isMaxValueMinusOne in terms of APInt instead of uint64_t.
Patch by Sheng Zhou.


---
Diffs of the changes:  (+4 -5)

 InstructionCombining.cpp |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.666 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.667
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.666	Mon Mar 19 16:08:07 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Mon Mar 19 16:10:28 2007
@@ -3449,14 +3449,13 @@
 
 // isMaxValueMinusOne - return true if this is Max-1
 static bool isMaxValueMinusOne(const ConstantInt *C, bool isSigned) {
+  uint32_t TypeBits = C->getType()->getPrimitiveSizeInBits();
   if (isSigned) {
     // Calculate 0111111111..11111
-    unsigned TypeBits = C->getType()->getPrimitiveSizeInBits();
-    int64_t Val = INT64_MAX;             // All ones
-    Val >>= 64-TypeBits;                 // Shift out unwanted 1 bits...
-    return C->getSExtValue() == Val-1;
+    APInt Val(APInt::getSignedMaxValue(TypeBits));
+    return C->getValue() == Val-1;
   }
-  return C->getZExtValue() == C->getType()->getBitMask()-1;
+  return C->getValue() == APInt::getAllOnesValue(TypeBits) - 1;
 }
 
 // isMinValuePlusOne - return true if this is Min+1






More information about the llvm-commits mailing list