[PATCH] D47522: [PM/LoopUnswitch] Add partial non-trivial unswitching for invariant conditions feeding a chain of `and`s or `or`s for a branch.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 5 14:54:36 PDT 2018


asbirlea added a comment.

Logic lgtm.



================
Comment at: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:162
+       make_range(std::next(Invariants.begin()), Invariants.end()))
+    if (Direction)
+      Cond = IRB.CreateOr(Cond, Invariant);
----------------
Nit (feel free to ignore): I would find clearer the intention if this was written as:
```
if (Direction)
   for all invariants
        Cond = CreateOr(Cond, Inv)
else
   for all invariants
        Cond = CreateAnd(Cond, Inv)
```
( or are you relying on this being unswitched in bootstrap? :-) )



================
Comment at: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:1809
+
+      // Replace it wit the 'continue' side if in the main loop body, and the
+      // unswitched if in the cloned blocks.
----------------
`with`


================
Comment at: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:1814
+      else if (DT.dominates(ClonedPH, UserI->getParent()))
+        U->set(UnswitchedReplacement);
+    }
----------------
Is it possible for neither LoopPH or ClonedPH to dominate the invariant use?


Repository:
  rL LLVM

https://reviews.llvm.org/D47522





More information about the llvm-commits mailing list