[LLVMdev] loop metdata instruction

Krzysztof Parzyszek kparzysz at codeaurora.org
Mon Feb 25 19:20:30 PST 2013


On 2/25/2013 7:41 PM, Redmond, Paul wrote:
>
> I'm suggesting this as a possible alternative to the loop latch approach.
> Please re-read my original email.

Your reply seemed like you're quoting code that is currently generated, 
not your proposal.

I'm not sure why you would want the loop metadata to be attached to some 
other branch.  Loop latch will always exist, while, at least at this 
time, there is no guarantee that the "other" branch (the loop guard) 
will exist.  Besides, there is a member function in the Loop class that 
gives you the latch block, from which you can easily get to the 
terminator and then the metadata.


As for the questionable part---I know that this is what clang generates, 
and there is probably little chance of changing it in near future, but 
this loop structure is just bad for optimization.  The loop, as it is 
generated, has an early exit and an unconditional latch.  What comes out 
of loop rotation in your example is what ideally it would be from the 
beginning.  Apart from all that, SimplifyCFG would have it a lot easier 
not to damage loops that at point may not even appear to be loops.

-Krzysztof

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation



More information about the llvm-dev mailing list