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

Chris Lattner lattner at cs.uiuc.edu
Wed Jul 23 10:23:17 PDT 2003


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.97 -> 1.98
ScalarReplAggregates.cpp updated: 1.6 -> 1.7

---
Log message:

Simplify code by using ConstantInt::getRawValue instead of checking to see 
whether the constant is signed or unsigned, then casting



---
Diffs of the changes:

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.97 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.98
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.97	Tue Jul 22 16:46:59 2003
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Wed Jul 23 10:22:24 2003
@@ -370,8 +370,7 @@
   if (Constant *Op1 = dyn_cast<Constant>(I.getOperand(1))) {
     if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
       const Type *Ty = CI->getType();
-      int64_t Val = Ty->isSigned() ?        cast<ConstantSInt>(CI)->getValue() :
-                                   (int64_t)cast<ConstantUInt>(CI)->getValue();
+      int64_t Val = (int64_t)cast<ConstantInt>(CI)->getRawValue();
       switch (Val) {
       case -1:                               // X * -1 -> -X
         return BinaryOperator::createNeg(Op0, I.getName());


Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.6 llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.7
--- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.6	Fri May 30 14:22:14 2003
+++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp	Wed Jul 23 10:22:25 2003
@@ -103,11 +103,7 @@
       Instruction *User = cast<Instruction>(*I);
       if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(User)) {
         // We now know that the GEP is of the form: GEP <ptr>, 0, <cst>
-        uint64_t Idx;
-        if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(GEPI->getOperand(2)))
-          Idx = CSI->getValue();
-        else
-          Idx = cast<ConstantUInt>(GEPI->getOperand(2))->getValue();
+        uint64_t Idx = cast<ConstantInt>(GEPI->getOperand(2))->getRawValue();
         
         assert(Idx < ElementAllocas.size() && "Index out of range?");
         AllocaInst *AllocaToUse = ElementAllocas[Idx];





More information about the llvm-commits mailing list