Skip to content

Commit 9321087

Browse files
committedJan 28, 2019
[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
1 parent 3720e2b commit 9321087

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,10 @@ static bool unswitchAllTrivialConditions(Loop &L, DominatorTree &DT,
847847
// Check if there are any side-effecting instructions (e.g. stores, calls,
848848
// volatile loads) in the part of the loop that the code *would* execute
849849
// without unswitching.
850+
if (MSSAU) // Possible early exit with MSSA
851+
if (auto *Defs = MSSAU->getMemorySSA()->getBlockDefs(CurrentBB))
852+
if (!isa<MemoryPhi>(*Defs->begin()) || (++Defs->begin() != Defs->end()))
853+
return Changed;
850854
if (llvm::any_of(*CurrentBB,
851855
[](Instruction &I) { return I.mayHaveSideEffects(); }))
852856
return Changed;

0 commit comments

Comments
 (0)
Please sign in to comment.