summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2019-01-28 17:48:45 +0000
committerAlina Sbirlea <asbirlea@google.com>2019-01-28 17:48:45 +0000
commit932108703a26491d4bda6723c1049fd50702d44d (patch)
tree3fa7922076b222abf47d03cfe552e4af465cdf31 /llvm/lib/Transforms
parent3720e2b39e4be7db2a62ff4447502e61f3681b59 (diff)
downloadbcm5719-llvm-932108703a26491d4bda6723c1049fd50702d44d.tar.gz
bcm5719-llvm-932108703a26491d4bda6723c1049fd50702d44d.zip
[SimpleLoopUnswitch] Early check exit for trivial unswitch with MemorySSA.
Summary: If MemorySSA is avaiable, we can skip checking all instructions if block has any Defs. (volatile loads are also Defs). We still need to check all instructions for "canThrow", even if no Defs are found. Reviewers: chandlerc Subscribers: sanjoy, jlebar, Prazek, george.burgess.iv, llvm-commits Differential Revision: https://reviews.llvm.org/D57129 llvm-svn: 352393
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index a50ca172a56..8113427cab7 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -847,6 +847,10 @@ static bool unswitchAllTrivialConditions(Loop &L, DominatorTree &DT,
// Check if there are any side-effecting instructions (e.g. stores, calls,
// volatile loads) in the part of the loop that the code *would* execute
// without unswitching.
+ if (MSSAU) // Possible early exit with MSSA
+ if (auto *Defs = MSSAU->getMemorySSA()->getBlockDefs(CurrentBB))
+ if (!isa<MemoryPhi>(*Defs->begin()) || (++Defs->begin() != Defs->end()))
+ return Changed;
if (llvm::any_of(*CurrentBB,
[](Instruction &I) { return I.mayHaveSideEffects(); }))
return Changed;
OpenPOWER on IntegriCloud