Skip to content

llvm.loop metadata incorrectly moved during loop-simplify pass #55416

@hgreving2304

Description

@hgreving2304

loop.ll.txt
cfg.dot.txt

When compiling attached boiled down example of code

llc ~/loop.ll -o - -print-after-all

The loop simplify pass (Canonicalize natural loops (loop-simplify)) IMO moves loop metadata incorrectly: The llvm.loop metadata attached to _bb6's terminator is moved to the new loop exit. I think the reason for this is that the loop exit is a header for another outer loop (see attached dotty graph). I think the loop metadata in this case should stay with the branch of the inner loop.

Error:

br i1 %cmp, label %_bb6, label %.loopexit, !llvm.loop !0

=> (after loop-simplify)

br i1 %cmp, label %_bb6, label %.loopexit.loopexit

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions