[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Jan 13 12:41:18 PST 2005
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.298 -> 1.299
---
Log message:
Fix some bugs in code I didn't mean to check in.
---
Diffs of the changes: (+12 -5)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.298 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.299
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.298 Thu Jan 13 14:14:25 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Thu Jan 13 14:40:58 2005
@@ -2112,6 +2112,7 @@
SIntPtrTy);
if (Constant *OpC = dyn_cast<Constant>(Op)) {
if (!OpC->isNullValue()) {
+ OpC = ConstantExpr::getCast(OpC, SIntPtrTy);
Scale = ConstantExpr::getMul(OpC, Scale);
if (Constant *RC = dyn_cast<Constant>(Result))
Result = ConstantExpr::getAdd(RC, Scale);
@@ -2123,13 +2124,19 @@
}
}
} else {
- // We'll let instcombine(mul) convert this to a shl if possible.
- Value *Offs =
- IC.InsertNewInstBefore(BinaryOperator::createMul(Op, Scale,
- GEP->getName()+".idx"), I);
+ //if (Op->getType() != Scale->getType())
+ if (Size != 1) {
+ // Convert to correct type.
+ Op = IC.InsertNewInstBefore(new CastInst(Op, SIntPtrTy,
+ Op->getName()+".c"), I);
+
+ // We'll let instcombine(mul) convert this to a shl if possible.
+ Op = IC.InsertNewInstBefore(BinaryOperator::createMul(Op, Scale,
+ GEP->getName()+".idx"), I);
+ }
// Emit an add instruction.
- Result = IC.InsertNewInstBefore(BinaryOperator::createAdd(Offs, Result,
+ Result = IC.InsertNewInstBefore(BinaryOperator::createAdd(Op, Result,
GEP->getName()+".offs"), I);
}
}
More information about the llvm-commits
mailing list