http://llvm.org/bugs/show_bug.cgi?id=15596

            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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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
"BackedgeBlocks.back()+1".

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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to