[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Wed Dec 8 15:10:41 PST 2004
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.289 -> 1.290
---
Log message:
Fix this regression and remove the XFAIL from this test.
---
Diffs of the changes: (+5 -3)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.289 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.290
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.289 Wed Dec 8 16:20:34 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Wed Dec 8 17:10:30 2004
@@ -4216,9 +4216,11 @@
// Instruction isn't dead, see if we can constant propagate it...
if (Constant *C = ConstantFoldInstruction(I)) {
+ Value* Ptr = I->getOperand(0);
if (isa<GetElementPtrInst>(I) &&
- cast<Constant>(I->getOperand(0))->isNullValue() &&
- !isa<ConstantPointerNull>(C)) {
+ cast<Constant>(Ptr)->isNullValue() &&
+ !isa<ConstantPointerNull>(C) &&
+ cast<PointerType>(Ptr->getType())->getElementType()->isSized()) {
// If this is a constant expr gep that is effectively computing an
// "offsetof", fold it into 'cast int X to T*' instead of 'gep 0, 0, 12'
bool isFoldableGEP = true;
@@ -4226,7 +4228,7 @@
if (!isa<ConstantInt>(I->getOperand(i)))
isFoldableGEP = false;
if (isFoldableGEP) {
- uint64_t Offset = TD->getIndexedOffset(I->getOperand(0)->getType(),
+ uint64_t Offset = TD->getIndexedOffset(Ptr->getType(),
std::vector<Value*>(I->op_begin()+1, I->op_end()));
C = ConstantUInt::get(Type::ULongTy, Offset);
C = ConstantExpr::getCast(C, TD->getIntPtrType());
More information about the llvm-commits
mailing list