[llvm] r352393 - [SimpleLoopUnswitch] Early check exit for trivial unswitch with MemorySSA.

Alina Sbirlea via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 28 09:48:45 PST 2019


Author: asbirlea
Date: Mon Jan 28 09:48:45 2019
New Revision: 352393

URL: http://llvm.org/viewvc/llvm-project?rev=352393&view=rev
Log:
[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

Modified:
    llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp?rev=352393&r1=352392&r2=352393&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp Mon Jan 28 09:48:45 2019
@@ -847,6 +847,10 @@ static bool unswitchAllTrivialConditions
     // 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;




More information about the llvm-commits mailing list