[PATCH] D65164: Define some basic terminology around loops in our documentation

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 14:00:48 PDT 2019


reames added a comment.

In D65164#1600459 <https://reviews.llvm.org/D65164#1600459>, @jdoerfert wrote:

> > The first point is is incorrect. A single loop header can be the header of multiple nested loops.
>
> I fear we disagree on the definition of "a loop".
>
> I was thinking we describe the `llvm::Loop` here as it is discovered by LoopInfo. 
>  It seems you want to go for something different (or I am too tired to see my mistake).
>  [For the record, I think it often make sense to use a different definition than the one
>
>   I want to see here. For now, I am worried about inconsistencies in our definitions and
>   wrt. to the implementation.]


It turns out you're absolutely right here.  I was *trying* to describe llvm::Loop, but apparently my own mental model was wrong here.

The case I had in mind was:
$ cat nested-example.ll

define void @nested() {
entry:

  br label %header

header:

  br i1 undef, label %header, label %outer_latch

outer_latch:

  br i1 undef, label %header, label %exit

exit:

  ret void

}

I was thinking of this as two loops, one containing the other.

But apparently I was wrong, the actually output was:
$ ../build/bin/opt nested-example.ll -analyze -loops
Printing analysis 'Natural Loop Information' for function 'nested':
Loop at depth 1 containing: %header<header><latch>,%outer_latch<latch><exiting>


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65164/new/

https://reviews.llvm.org/D65164





More information about the llvm-commits mailing list