[llvm-dev] SimplifyCFG, llvm.loop and latch blocks

Jeroen Dobbelaere via llvm-dev llvm-dev at lists.llvm.org
Wed Apr 7 10:17:23 PDT 2021


Hi all,

https://llvm.org/docs/LangRef.html#llvm-loop  states that a llvm.loop is put on the
'branch instruction of the loop's latch block'.

With 'SimplifyCFG', I have come in a situation where a !llvm.loop is associated to
a basicblock that is found to be a latch block for two different loops.

The original annotation of one of those loops disappeared in the process.
(See  https://www.godbolt.org/z/5r1T5e9fs  and look for the disappearing !llvm.loop !10  in BB 'do.cond')


Then later on,  'Canonicalize natural loops' splits the latch block up, so that it now is only
the latch block for a single loop, but the original annotation is moved to the wrong loop.


Questions:
- The branch in 'do.cond' is simplified, but I have the impression that at the same time, the loop annotation is omitted.
  This sounds like a bug ?
- Is it a correct assumption that we should not merge blocks if both have a branch instruction with a !llvm.loop annotation set ?

Thanks,

Jeroen Dobbelaere
 


More information about the llvm-dev mailing list