[llvm-commits] [llvm] r77286 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Dan Gohman gohman at apple.com
Mon Jul 27 17:37:50 PDT 2009


Author: djg
Date: Mon Jul 27 19:37:50 2009
New Revision: 77286

URL: http://llvm.org/viewvc/llvm-project?rev=77286&view=rev
Log:
Replace dyn_castGetElementPtr with dyn_cast<GEPOperator>.

Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=77286&r1=77285&r2=77286&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Jul 27 19:37:50 2009
@@ -628,16 +628,6 @@
   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 @@
 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 @@
       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 @@
   }
 
   // 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 @@
   // 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()) {





More information about the llvm-commits mailing list