summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2015-12-16 14:12:44 +0000
committerJames Molloy <james.molloy@arm.com>2015-12-16 14:12:44 +0000
commit3d21dcf3edf54391749d00638bb8addea342d6e9 (patch)
treee83a29b57f58595143afef635ac16b16d151b5ce /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent0b135e05ec5cf7bf9094bc6d8e1fd9cd703a9a5d (diff)
downloadbcm5719-llvm-3d21dcf3edf54391749d00638bb8addea342d6e9.tar.gz
bcm5719-llvm-3d21dcf3edf54391749d00638bb8addea342d6e9.zip
[SimplifyCFG] Don't create unnecessary PHIs
In conditional store merging, we were creating PHIs when we didn't need to. If the value to be predicated isn't defined in the block we're predicating, then it doesn't need a PHI at all (because we only deal with triangles and diamonds, any value not in the predicated BB must dominate the predicated BB). This fixes a large code size increase in some benchmarks in a popular embedded benchmark suite. Now with a fix (and fixed tests) for the conformance issue seen in Chromium. llvm-svn: 255767
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index ab281ef1edb..d0932f834cf 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2419,6 +2419,11 @@ static Value *ensureValueAvailableInSuccessor(Value *V, BasicBlock *BB,
if (PHI)
return PHI;
+ // If V is not an instruction defined in BB, just return it.
+ if (!AlternativeV &&
+ (!isa<Instruction>(V) || cast<Instruction>(V)->getParent() != BB))
+ return V;
+
PHI = PHINode::Create(V->getType(), 2, "simplifycfg.merge", &Succ->front());
PHI->addIncoming(V, BB);
for (BasicBlock *PredBB : predecessors(Succ))
OpenPOWER on IntegriCloud