diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-07 04:45:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-07 04:45:13 +0000 |
commit | 71068a046218544b56392f9fae43af2b780183aa (patch) | |
tree | 16b79e0b3062d4a49f0ded2af921bb0a9f4a4989 /llvm/lib | |
parent | e549717d841fa5895c2583f3d68c60964b959691 (diff) | |
download | bcm5719-llvm-71068a046218544b56392f9fae43af2b780183aa.tar.gz bcm5719-llvm-71068a046218544b56392f9fae43af2b780183aa.zip |
When folding constant expr gep's, don't force the use of long indices.
llvm-svn: 14658
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/VMCore/ConstantFolding.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/ConstantFolding.cpp b/llvm/lib/VMCore/ConstantFolding.cpp index a57606669d3..5a8e41c74ea 100644 --- a/llvm/lib/VMCore/ConstantFolding.cpp +++ b/llvm/lib/VMCore/ConstantFolding.cpp @@ -993,11 +993,14 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, // Add the last index of the source with the first index of the new GEP. // Make sure to handle the case when they are actually different types. Constant *Combined = CE->getOperand(CE->getNumOperands()-1); - if (!IdxList[0]->isNullValue()) // Otherwise it must be an array + if (!IdxList[0]->isNullValue()) { // Otherwise it must be an array + const Type *IdxTy = Combined->getType(); + if (IdxTy != IdxList[0]->getType()) IdxTy = Type::LongTy; Combined = ConstantExpr::get(Instruction::Add, - ConstantExpr::getCast(IdxList[0], Type::LongTy), - ConstantExpr::getCast(Combined, Type::LongTy)); + ConstantExpr::getCast(IdxList[0], IdxTy), + ConstantExpr::getCast(Combined, IdxTy)); + } NewIndices.push_back(Combined); NewIndices.insert(NewIndices.end(), IdxList.begin()+1, IdxList.end()); |