From 15b7f5b72d2ae3dae37a42caa8d3259cfafc70c6 Mon Sep 17 00:00:00 2001 From: Whitney Tsang Date: Mon, 17 Jun 2019 14:38:56 +0000 Subject: PHINode: introduce setIncomingValueForBlock() function, and use it. Summary: There is PHINode::getBasicBlockIndex() and PHINode::setIncomingValue() but no function to replace incoming value for a specified BasicBlock* predecessor. Clearly, there are a lot of places that could use that functionality. Reviewer: craig.topper, lebedev.ri, Meinersbur, kbarton, fhahn Reviewed By: Meinersbur, fhahn Subscribers: fhahn, hiraditya, zzheng, jsji, llvm-commits Tag: LLVM Differential Revision: https://reviews.llvm.org/D63338 llvm-svn: 363566 --- llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp') diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp index 03f3132..b39d78d 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp @@ -124,11 +124,10 @@ static void ConnectProlog(Loop *L, Value *BECount, unsigned Count, // Update the existing PHI node operand with the value from the // new PHI node. How this is done depends on if the existing // PHI node is in the original loop block, or the exit block. - if (L->contains(&PN)) { - PN.setIncomingValue(PN.getBasicBlockIndex(NewPreHeader), NewPN); - } else { + if (L->contains(&PN)) + PN.setIncomingValueForBlock(NewPreHeader, NewPN); + else PN.addIncoming(NewPN, PrologExit); - } } } @@ -264,7 +263,7 @@ static void ConnectEpilog(Loop *L, Value *ModVal, BasicBlock *NewExit, // Update the existing PHI node operand with the value from the new PHI // node. Corresponding instruction in epilog loop should be PHI. PHINode *VPN = cast(VMap[&PN]); - VPN->setIncomingValue(VPN->getBasicBlockIndex(EpilogPreHeader), NewPN); + VPN->setIncomingValueForBlock(EpilogPreHeader, NewPN); } } -- cgit v1.1