summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-21 23:06:49 +0000
committerChris Lattner <sabre@nondot.org>2005-01-21 23:06:49 +0000
commitfc4429e7c1681968280a477032b7e506ff67b2a7 (patch)
tree84128f64a386991e8b8b76b83f0f404a9e79bfb7 /llvm/lib/Transforms
parente70eb9da7d6d9e85d23bcad6d5a0f8d1ae9c5852 (diff)
downloadbcm5719-llvm-fc4429e7c1681968280a477032b7e506ff67b2a7.tar.gz
bcm5719-llvm-fc4429e7c1681968280a477032b7e506ff67b2a7.zip
Handle comparisons of gep instructions that have different typed indices
as long as they are the same size. llvm-svn: 19734
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 6312f426dd3..080bc78943a 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2244,9 +2244,9 @@ Instruction *InstCombiner::FoldGEPSetCC(User *GEPLHS, Value *RHS,
unsigned DiffOperand = 0; // The operand that differs.
for (unsigned i = 1, e = GEPRHS->getNumOperands(); i != e; ++i)
if (GEPLHS->getOperand(i) != GEPRHS->getOperand(i)) {
- if (GEPLHS->getOperand(i)->getType() !=
- GEPRHS->getOperand(i)->getType()) {
- // Irreconsilable differences.
+ if (GEPLHS->getOperand(i)->getType()->getPrimitiveSize() !=
+ GEPRHS->getOperand(i)->getType()->getPrimitiveSize()) {
+ // Irreconcilable differences.
NumDifferences = 2;
break;
} else {
@@ -2259,8 +2259,12 @@ Instruction *InstCombiner::FoldGEPSetCC(User *GEPLHS, Value *RHS,
return ReplaceInstUsesWith(I, // No comparison is needed here.
ConstantBool::get(Cond == Instruction::SetEQ));
else if (NumDifferences == 1) {
- return new SetCondInst(Cond, GEPLHS->getOperand(DiffOperand),
- GEPRHS->getOperand(DiffOperand));
+ Value *LHSV = GEPLHS->getOperand(DiffOperand);
+ Value *RHSV = GEPRHS->getOperand(DiffOperand);
+ if (LHSV->getType() != RHSV->getType())
+ LHSV = InsertNewInstBefore(new CastInst(LHSV, RHSV->getType(),
+ LHSV->getName()+".c"), I);
+ return new SetCondInst(Cond, LHSV, RHSV);
}
}
OpenPOWER on IntegriCloud