[PowerPC] handle more than two predecessors loop header in ctrloop pass
authorChen Zheng <czhengsz@cn.ibm.com>
Thu, 13 Oct 2022 01:49:02 +0000 (01:49 +0000)
committerChen Zheng <czhengsz@cn.ibm.com>
Wed, 19 Oct 2022 01:11:58 +0000 (01:11 +0000)
commitdf9d60af1f9fa44f411b656bbc691d950c6fc087
treee282941bb376f378438a3a6f1bab266e5e87dcb5
parent13d6a57cbe2776c4873302c0cf04e27b77bd2862
[PowerPC] handle more than two predecessors loop header in ctrloop pass

After ISEL, the "valid" loop header which has two predecessors
(one is preheader and the other one is latch) may be transformed
to have more than two predecessors by some optimizations, like tail
duplicator, if the old header's successor(will be changed to new
header) is a sub loop.

The predecessors of the new loop header are preheader, loop latch
and the loop latch(es) of the sub loop(old header's successor).

Before the patch, ctrloop pass assumes two predecessors for candidate
loop header. This patch fixes this case.

Reviewed By: lkail

Differential Revision: https://reviews.llvm.org/D135846
llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
llvm/test/CodeGen/PowerPC/ctrloop-header-multiple-preds.mir [new file with mode: 0644]