[PATCH] Fix for LoopUnroll pass was breaking LCSSA form while completely removing loop [PR18861]

Dinesh Dwivedi dinesh.d at samsung.com
Wed Feb 26 00:10:34 PST 2014


I have attached patch to fix PR18861. I am still looking in to this issue. Here is my analysis.

If LoopUnroll pass decides to completely unroll a loop, before deleting it [deleteLoopFromQueue()] from the loop list,
it updates parent loop for all blocks in the loop to be unrolled [updateUnloop()->updateBlockParents()]. Candidate for 
parent loop is based on finding nearest parent loop among the block successors [getNearestLoop()], and returns null if 
a block does not have any successor [e.g. exit blocks having return statement, not sure if this may happen in other 
cases]. This causes the block to come out of loop nest. Now if this block is using some variable assigned inside loop 
nest, then it breaks LCSSA form.

In test case for this bug, value assigned in top loop was used in inner-most loop's exit block. Unrolling this inner-most 
loop was putting the exit block outside loop resulting ill-formed LCSSA.

I am working on the solution for reforming LCSSA for basic blocks when the come out of the loop nest. This requires iterating
through all values used in the block and then find loop that assigns them and adding PHI nodes from all predecessors of the block.
I am new to this and still need to understand how to add phi nodes, replace all the uses in the current block with this new variable,
if I have to check relation between block predecessors and loop that assigns values etc.

Regards
Dinesh Dwivedi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PR18861.diff
Type: application/octet-stream
Size: 2911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140226/a834a0b8/attachment.obj>


More information about the llvm-commits mailing list