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

Chris Lattner lattner at cs.uiuc.edu
Sat Feb 14 23:56:13 PST 2004


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.151 -> 1.152
SCCP.cpp updated: 1.88 -> 1.89

---
Log message:

Adjustments to support the new ConstantAggregateZero class



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

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.151 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.152
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.151	Sun Feb  8 15:43:50 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Sat Feb 14 23:55:10 2004
@@ -2088,11 +2088,13 @@
   // addressing...
   for (unsigned i = 2, e = CE->getNumOperands(); i != e; ++i)
     if (ConstantUInt *CU = dyn_cast<ConstantUInt>(CE->getOperand(i))) {
-      ConstantStruct *CS = cast<ConstantStruct>(C);
+      ConstantStruct *CS = dyn_cast<ConstantStruct>(C);
+      if (CS == 0) return 0;
       if (CU->getValue() >= CS->getValues().size()) return 0;
       C = cast<Constant>(CS->getValues()[CU->getValue()]);
     } else if (ConstantSInt *CS = dyn_cast<ConstantSInt>(CE->getOperand(i))) {
-      ConstantArray *CA = cast<ConstantArray>(C);
+      ConstantArray *CA = dyn_cast<ConstantArray>(C);
+      if (CA == 0) return 0;
       if ((uint64_t)CS->getValue() >= CA->getValues().size()) return 0;
       C = cast<Constant>(CA->getValues()[CS->getValue()]);
     } else 


Index: llvm/lib/Transforms/Scalar/SCCP.cpp
diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.88 llvm/lib/Transforms/Scalar/SCCP.cpp:1.89
--- llvm/lib/Transforms/Scalar/SCCP.cpp:1.88	Mon Jan 12 13:08:43 2004
+++ llvm/lib/Transforms/Scalar/SCCP.cpp	Sat Feb 14 23:55:10 2004
@@ -689,14 +689,16 @@
   // addressing...
   for (unsigned i = 2, e = CE->getNumOperands(); i != e; ++i)
     if (ConstantUInt *CU = dyn_cast<ConstantUInt>(CE->getOperand(i))) {
-      ConstantStruct *CS = cast<ConstantStruct>(C);
+      ConstantStruct *CS = dyn_cast<ConstantStruct>(C);
+      if (CS == 0) return 0;
       if (CU->getValue() >= CS->getValues().size()) return 0;
       C = cast<Constant>(CS->getValues()[CU->getValue()]);
     } else if (ConstantSInt *CS = dyn_cast<ConstantSInt>(CE->getOperand(i))) {
-      ConstantArray *CA = cast<ConstantArray>(C);
+      ConstantArray *CA = dyn_cast<ConstantArray>(C);
+      if (CA == 0) return 0;
       if ((uint64_t)CS->getValue() >= CA->getValues().size()) return 0;
       C = cast<Constant>(CA->getValues()[CS->getValue()]);
-    } else 
+    } else
       return 0;
   return C;
 }





More information about the llvm-commits mailing list