The current implementation of getLoopID seems incorrect as it returns nullptr only after looking into the successors of first block in the loop.
In the setLoopID, there is no need to iterate over all the basic blocks of loop as loop metadata is only associated with predecessor (s) of loop header.
Details
- Reviewers
sebpop paul.redmond spatel sanjoy
Diff Detail
Event Timeline
llvm/lib/Analysis/LoopInfo.cpp | ||
---|---|---|
253 | I'll remove this assert. THanks, |
llvm/lib/Analysis/LoopInfo.cpp | ||
---|---|---|
214–215 | AFAIU, this->contains would be as expensive, as iterating through all blocks (as we did in the original version). Moreover, now we'll do it several times while in the original code we did that only once. Are you sure it's worth it? The issue you mentioned - getLoopID returns nullptr only after looking into the successors of the first block in the loop - still looks relevant though, so some fix is indeed needed. | |
247–248 | Same question about the cost of this->contains versus original iterating over all blocks. |
llvm/lib/Analysis/LoopInfo.cpp | ||
---|---|---|
214–215 |
Only for loops with few basic blocks, because DenseBlockSet is a SmallPtrSet, whereas in the previous implementation it would iterate through all the basic blocks and all the successors of each BB in the loop. |
This comment is stale now.