[llvm-dev] Making loop guards part of canonical loop structure

Philip Reames via llvm-dev llvm-dev at lists.llvm.org
Thu May 30 13:00:26 PDT 2019

Er, I'm missing something.  Every loop header is guaranteed to execute
at least once, if the preheader is reached.  How is what you need
anything more than a loop header with a unique predecessor (preheader)? 
I'm not seeing the need for a guard block in what you said.


On 5/30/19 11:28 AM, Krzysztof Parzyszek via llvm-dev wrote:
> On Hexagon, unguarded loops cannot be converted to hardware loops.
> If the loop's latch branch alone handles the iteration count, including the possibility of 0, then the loop cannot be converted to a hardware loop, because hardware loops must iterate at least once.  If the entire loop is guarded against zero iteration count, we can put the loop setup in the preheader, since at that point the loop is guaranteed to execute at least once.
> I am strongly in favor of having some way to create loop guards, even if they are trivial.

More information about the llvm-dev mailing list