aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-28 00:37:50 +0000
committerDan Gohman <gohman@apple.com>2009-07-28 00:37:50 +0000
commita117c6c8ff6658b26760bcccfa83c0339efc6004 (patch)
tree878195939041551a42069e48aba3524b276ee792
parentc6f29cc7f5b1e8e68f3d9f1a5f04da2e943db3fe (diff)
downloadexternal_llvm-a117c6c8ff6658b26760bcccfa83c0339efc6004.zip
external_llvm-a117c6c8ff6658b26760bcccfa83c0339efc6004.tar.gz
external_llvm-a117c6c8ff6658b26760bcccfa83c0339efc6004.tar.bz2
Replace dyn_castGetElementPtr with dyn_cast<GEPOperator>.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77286 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index a6538dc..9a53ea6 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -628,16 +628,6 @@ static inline Value *dyn_castFoldableMul(Value *V, ConstantInt *&CST,
return 0;
}
-/// dyn_castGetElementPtr - If this is a getelementptr instruction or constant
-/// expression, return it.
-static User *dyn_castGetElementPtr(Value *V) {
- if (isa<GetElementPtrInst>(V)) return cast<User>(V);
- if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
- if (CE->getOpcode() == Instruction::GetElementPtr)
- return cast<User>(V);
- return false;
-}
-
/// AddOne - Add one to a ConstantInt
static Constant *AddOne(Constant *C, LLVMContext *Context) {
return Context->getConstantExprAdd(C,
@@ -5572,7 +5562,7 @@ static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I,
Instruction *InstCombiner::FoldGEPICmp(User *GEPLHS, Value *RHS,
ICmpInst::Predicate Cond,
Instruction &I) {
- assert(dyn_castGetElementPtr(GEPLHS) && "LHS is not a getelementptr!");
+ assert(isa<GEPOperator>(GEPLHS) && "LHS is not a getelementptr!");
// Look through bitcasts.
if (BitCastInst *BCI = dyn_cast<BitCastInst>(RHS))
@@ -5590,7 +5580,7 @@ Instruction *InstCombiner::FoldGEPICmp(User *GEPLHS, Value *RHS,
Offset = EmitGEPOffset(GEPLHS, I, *this);
return new ICmpInst(*Context, ICmpInst::getSignedPredicate(Cond), Offset,
Context->getNullValue(Offset->getType()));
- } else if (User *GEPRHS = dyn_castGetElementPtr(RHS)) {
+ } else if (User *GEPRHS = dyn_cast<GEPOperator>(RHS)) {
// If the base pointers are different, but the indices are the same, just
// compare the base pointer.
if (PtrBase != GEPRHS->getOperand(0)) {
@@ -6355,10 +6345,10 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
}
// If we can optimize a 'icmp GEP, P' or 'icmp P, GEP', do so now.
- if (User *GEP = dyn_castGetElementPtr(Op0))
+ if (User *GEP = dyn_cast<GEPOperator>(Op0))
if (Instruction *NI = FoldGEPICmp(GEP, Op1, I.getPredicate(), I))
return NI;
- if (User *GEP = dyn_castGetElementPtr(Op1))
+ if (User *GEP = dyn_cast<GEPOperator>(Op1))
if (Instruction *NI = FoldGEPICmp(GEP, Op0,
ICmpInst::getSwappedPredicate(I.getPredicate()), I))
return NI;
@@ -11065,7 +11055,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// getelementptr instructions into a single instruction.
//
SmallVector<Value*, 8> SrcGEPOperands;
- if (User *Src = dyn_castGetElementPtr(PtrOp))
+ if (User *Src = dyn_cast<GEPOperator>(PtrOp))
SrcGEPOperands.append(Src->op_begin(), Src->op_end());
if (!SrcGEPOperands.empty()) {