[PATCH] D54021: [LoopSimplifyCFG] Teach LoopSimplifyCFG to constant-fold branches and switches

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 16 03:41:12 PST 2018


mkazantsev added inline comments.


================
Comment at: lib/Transforms/Scalar/LoopSimplifyCFG.cpp:192
+    // The loop will not be destroyed if its latch is live.
+    DeleteCurrentLoop = !IsEdgeLive(L.getLoopLatch(), L.getHeader());
+
----------------
mkazantsev wrote:
> anna wrote:
> > I find this name misleading because the current loop can be deleted in 2 ways:
> > 1. latch to header edge is dead
> > 2. edge to header from outside this loop is dead
> > 
> > Second case does not happen now, because you only consider blocks in current loop as candidate for folding. 
> > 
> > However, I think you need to add both cases for completeness here. 
> > 
> > 
> > 
> > 
> Technically, we only modify the current loop and cannot change anything outside this loop, so 2nd case is just out of scope.
I've added an explanatory comment why the second case is impossible in the field's comment.


https://reviews.llvm.org/D54021





More information about the llvm-commits mailing list