X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FCodeGenPrepare.cpp;fp=lib%2FCodeGen%2FCodeGenPrepare.cpp;h=d7037a9320013c7b5d427ff189558832a2ac0136;hb=01fcec965e45a246e8f00596467dae3d48eab695;hp=5c9858dcec2f3cc2cb0975322800992b670f96a1;hpb=20a42bb20d43b80e322c95dd99b64a5a4566fe08;p=oota-llvm.git diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp index 5c9858dcec2..d7037a93200 100644 --- a/lib/CodeGen/CodeGenPrepare.cpp +++ b/lib/CodeGen/CodeGenPrepare.cpp @@ -667,32 +667,23 @@ Instruction* findFirstStoreCondBranchInst(LoadInst* LI) { auto BE = BB->end(); auto BBI = BasicBlock::iterator(LI); BBI++; - while (true) { - for (; BBI != BE; BBI++) { - auto* Inst = dyn_cast(&*BBI); - if (Inst == nullptr) { - continue; - } - if (Inst->getOpcode() == Instruction::Store) { + for (; BBI != BE; BBI++) { + auto* Inst = dyn_cast(&*BBI); + if (Inst == nullptr) { + continue; + } + if (Inst->getOpcode() == Instruction::Store) { + return Inst; + } else if (Inst->getOpcode() == Instruction::Br) { + auto* BrInst = dyn_cast(Inst); + if (BrInst->isConditional()) { return Inst; - } else if (Inst->getOpcode() == Instruction::Br) { - auto* BrInst = dyn_cast(Inst); - if (BrInst->isConditional()) { - return Inst; - } else { - // Reinitialize iterators with the destination of the unconditional - // branch. - BB = BrInst->getSuccessor(0); - BBI = BB->begin(); - BE = BB->end(); - break; - } + } else { + return nullptr; } } - if (BBI == BE) { - return nullptr; - } } + return nullptr; } // XXX-comment: Returns whether the code has been changed. @@ -780,7 +771,8 @@ bool AddFakeConditionalBranchAfterMonotonicLoads( if (StoreAddressDependOnValue(dyn_cast(FirstInst), LI)) { continue; } - } else if (FirstInst->getOpcode() == Instruction::Br) { + } else if (FirstInst->getOpcode() == Instruction::Br && + isa(FirstInst)) { if (ConditionalBranchDependsOnValue(dyn_cast(FirstInst), LI)) { continue;