[PATCH] D18158: Adding ability to unroll loops using epilogue remainder.

Michael Zolotukhin via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 29 18:52:19 PDT 2016


mzolotukhin added inline comments.

================
Comment at: lib/Transforms/Utils/LoopUnrollRuntime.cpp:549-550
@@ -341,6 +548,4 @@
   Value *TripCount = Expander.expandCodeFor(TripCountSC, TripCountSC->getType(),
                                             PreHeaderBR);
-  Value *BECount = Expander.expandCodeFor(BECountSC, BECountSC->getType(),
-                                          PreHeaderBR);
-
+  Value *BECount = nullptr;
   IRBuilder<> B(PreHeaderBR);
----------------
evstupac wrote:
> The other point here is that to expand BECount before actual use we'll need to recompute PreHeaderBR, as it is deleted at line 602.
This makes sense now, thanks. I still feel uneasy about this function though, it's becoming kind of a spaghetti code. Would it be possible to refactor it a bit to get rid of multiple `if (UseEpilogRemainder)`? I think now the amount of code that is shared between these two cases isn't much bigger than the amount of code that is different. If we shuffle the code around (where possible), and factor out some common blocks to helper functions, we can keep only one `if (UseEpilogRemainder)`, or rather have two specialized functions.


Repository:
  rL LLVM

http://reviews.llvm.org/D18158





More information about the llvm-commits mailing list