From 02dea8b39f3acad5de1df36273444d149145e7fc Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 23 May 2008 21:05:58 +0000 Subject: Tidy up BasicBlock::getFirstNonPHI, and change a bunch of places to use it instead of duplicating its functionality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51499 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/CodeGenPrepare.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'lib/Transforms/Scalar/CodeGenPrepare.cpp') diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp index 959a832004..732aa5b547 100644 --- a/lib/Transforms/Scalar/CodeGenPrepare.cpp +++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp @@ -385,8 +385,7 @@ static bool OptimizeNoopCopyExpression(CastInst *CI, const TargetLowering &TLI){ CastInst *&InsertedCast = InsertedCasts[UserBB]; if (!InsertedCast) { - BasicBlock::iterator InsertPt = UserBB->begin(); - while (isa(InsertPt)) ++InsertPt; + BasicBlock::iterator InsertPt = UserBB->getFirstNonPHI(); InsertedCast = CastInst::Create(CI->getOpcode(), CI->getOperand(0), CI->getType(), "", @@ -443,8 +442,7 @@ static bool OptimizeCmpExpression(CmpInst *CI){ CmpInst *&InsertedCmp = InsertedCmps[UserBB]; if (!InsertedCmp) { - BasicBlock::iterator InsertPt = UserBB->begin(); - while (isa(InsertPt)) ++InsertPt; + BasicBlock::iterator InsertPt = UserBB->getFirstNonPHI(); InsertedCmp = CmpInst::Create(CI->getOpcode(), CI->getPredicate(), CI->getOperand(0), @@ -1039,8 +1037,7 @@ bool CodeGenPrepare::OptimizeExtUses(Instruction *I) { Instruction *&InsertedTrunc = InsertedTruncs[UserBB]; if (!InsertedTrunc) { - BasicBlock::iterator InsertPt = UserBB->begin(); - while (isa(InsertPt)) ++InsertPt; + BasicBlock::iterator InsertPt = UserBB->getFirstNonPHI(); InsertedTrunc = new TruncInst(I, Src->getType(), "", InsertPt); } -- cgit v1.2.3-18-g5258