[PATCH] D54223: [SimpleLoopUnswitch] adding cost multiplier to cap exponential unswitch with

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 14 15:24:55 PST 2018


chandlerc added inline comments.


================
Comment at: lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:2307-2308
+                               : std::distance(LI.begin(), LI.end()));
+  // Count candidates - branch/guard counts as 1, switch counts as
+  // log2 of its cases.
+  int CandidatesNum = 0;
----------------
chandlerc wrote:
> fedor.sergeev wrote:
> > chandlerc wrote:
> > > I'd change the name here. You're not counting candidates, you're counting unswitched clones I think.
> > > 
> > > To that end, should you do the same filtering here that you do above for guards and exiting conditions?
> > Hmm... yes, filtering them here makes sense.
> > Speaking of which, I dont believe my filtering is right for the switch.
> > Even if switch has one exiting case it still can have many other cases remaining for the unswitch (and thus duplication of loops).
> > Will try to do something here, though for now I'm still going to keep it "simple" ... at least to the extent possible.
> I'd change here and above to skip when: `DT.dominates(CondBlock, Latch) && (isGuard(&TI) || CondBlock->getNumSuccessors() - count_if(CondBlock->successors(), [](BasicBlock *SuccBB) { return !L.contains(SuccBB); }) <= 1)`.
Er, that should somewhat obviously be: `DT.dominates(CondBlock, Latch) && (isGuard(&TI) || count_if(CondBlock->successors(), [](BasicBlock *SuccBB) { return L.contains(SuccBB); }) <= 1)`


Repository:
  rL LLVM

https://reviews.llvm.org/D54223





More information about the llvm-commits mailing list