LLVM: llvm::LoopConstrainer Class Reference (original) (raw)
This class is used to constrain loops to run within a given iteration space. More...
This class is used to constrain loops to run within a given iteration space.
The algorithm this class implements is given a Loop and a range [Begin, End). The algorithm then tries to break out a "main loop" out of the loop it is given in a way that the "main loop" runs with the induction variable in a subset of [Begin, End). The algorithm emits appropriate pre and post loops to run any remaining iterations. The pre loop runs any iterations in which the induction variable is < Begin, and the post loop runs any iterations in which the induction variable is >= End.
Definition at line 95 of file LoopConstrainer.h.
| bool LoopConstrainer::run | ( | ) |
|---|
At this point:
- We've broken a "main loop" out of the loop in a way that the "main loop" runs with the induction variable in a subset of [Begin, End).
- There is no overflow when computing "main loop" exit limit.
- Max latch taken count of the loop is limited. It guarantees that induction variable will not overflow iterating in the "main loop".
TODO: support unsigned predicate. To add NUW flag we need to prove that both operands of BO are non-negative. E.g: ... iv.next = add nsw i32 iv, -1 cmp = icmp ult i32 iv.next, n br i1 cmp, label loopexit, label loop
-1 is MAX_UINT in terms of unsigned int. Adding anything but zero will overflow, therefore NUW flag is not legal here.
Definition at line 726 of file LoopConstrainer.cpp.
References llvm::ArrayRef(), assert(), llvm::cannotBeMinInLoop(), llvm::cast(), llvm::dbgs(), DisableAllLoopOptsOnLoop(), llvm::SCEVExpander::expandCodeFor(), llvm::formLCSSARecursively(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getTerminator(), llvm::LoopStructure::Header, llvm::isa(), llvm::SCEVExpander::isSafeToExpandAt(), LLVM_DEBUG, llvm::User::replaceUsesOfWith(), llvm::Value::setName(), and llvm::simplifyLoop().