[LLVMbugs] [Bug 15596] New: LoopSimplify inserts backedge block in wrong spot

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 26 05:42:27 PDT 2013


            Bug ID: 15596
           Summary: LoopSimplify inserts backedge block in wrong spot
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: tim.besard at elis.ugent.be
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

When a loop contains multiple backedges, LoopSimplify inserts a new backedge in
order to ensure that all loops have exactly one backedge
(LoopSimplify::InsertUniqueBackedgeBlock). When inserting the newly created
back-edge, the comments detail that the block is to be inserted right after the
last backedge block. This is implemented by inserting before

However, BackedgeBlocks is filled by a loop which iterates over the
predecessors of the loop header. As it seems, pred_iterator does not iterate
the predecessors in order of occurrence in the program, but (as far as I see)
the other way around: it starts with the last predecessor, and ends up with the
first one.

This means that "BackedgeBlocks.back()+1" actually points to right after the
first backedge block, rather than the last one.

I don't know whether pred_iterator is supposed to iterate the predecessors from
last predecessor to the first one, but if it is I think it would suffice to
change "InsertPos = BackedgeBlocks.back()" to "BackedgeBlocks.front()" in order
to get the documented behaviour.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130326/d40fa878/attachment.html>

More information about the llvm-bugs mailing list