[PATCH] D29331: [LICM] Hoist loads that are dominated by invariant.start intrinsic, and are invariant in the loop.
Anna Thomas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 1 11:14:26 PST 2017
anna added inline comments.
Comment at: lib/Transforms/Scalar/LICM.cpp:508
+ // Avoid traversing for LoadOperand with high number of users.
+ if (LoadOp->getNumUses() > MaxNumUses)
+ return false;
> You're not saving any time by this, since `getNumUses()` is O(# uses).
> I think you need a `if (UsesSeen++ > MaxNumUses) return false;` type thing in the loop below.
Comment at: lib/Transforms/Scalar/LICM.cpp:535
+ // load out of a loop that contains this dominating invariant.start
+ if (DT->dominates(II, LI) && !CurLoop->contains(II->getParent()))
+ return true;
> I think just checking `DT->dominates(II, LoopPreHeader)` is sufficient here.
that's right. I missed that the `LoopPreheader` is guaranteed to exist in loops that have LICM done on them (all these loops are in `LCSSA` form).
More information about the llvm-commits