diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-01-13 20:40:58 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-01-13 20:40:58 +0000 |
| commit | 4cb9fa373b8874f641975ab48d38d7fe4310e6c2 (patch) | |
| tree | a9d34ee293d28a147f1708aa12e30e6f7a13fb24 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
| parent | 0798af33a581c319bc3ef2ee5bdd1d6a7dd9b918 (diff) | |
| download | bcm5719-llvm-4cb9fa373b8874f641975ab48d38d7fe4310e6c2.tar.gz bcm5719-llvm-4cb9fa373b8874f641975ab48d38d7fe4310e6c2.zip | |
Fix some bugs in code I didn't mean to check in.
llvm-svn: 19534
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index d21ec762152..9f6e712e254 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2112,6 +2112,7 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) { 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 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) { } } } 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); } } |

