[PATCH] D16984: Don't delete empty preheaders in CodeGenPrepare if it would create a critical edge

Kit Barton via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 10:29:44 PDT 2016


kbarton accepted this revision.
kbarton added a comment.
This revision is now accepted and ready to land.

LGTM.
Note that the only test case I looked at in detail was dont-remove-empty-preheader.ll


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:372
@@ +371,3 @@
+  SmallVector<Loop *, 16> LoopList(LI->begin(), LI->end());
+  while (!LoopList.empty()) {
+    Loop *L = LoopList.pop_back_val();
----------------
This wasn't immediately obvious to me either. 
This is needed because of nested loops. The begin() and end() iterators for LoopInfo just contain the topmost loops for a given depth (nest level). For each loop in the list you need to:
  1. Check its preheader;
  2. Add all of the loops contained within it. Line 374 handles adding the topmost loops within the current loop body. 


http://reviews.llvm.org/D16984





More information about the llvm-commits mailing list