[SimplifyCFG] FoldBranchToCommonDest(): re-lift restrictions on liveout uses of bonus...
authorRoman Lebedev <lebedev.ri@gmail.com>
Fri, 22 Jan 2021 19:18:34 +0000 (22:18 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Fri, 22 Jan 2021 22:29:05 +0000 (01:29 +0300)
commit17422038442c9e2b572c7324b5a22d32e7fd9b83
tree84cb08a8c7f66c96ef013560d8f28c420091d121
parenteae1cc0de5b9c3b97ce1b6f4275b474ab10b83d0
[SimplifyCFG] FoldBranchToCommonDest(): re-lift restrictions on liveout uses of bonus instructions

I have previously tried doing that in
b33fbbaa34f0fe9fb16789afc72ae424c1825b69 / d38205144febf4dc42c9270c6aa3d978f1ef65e1,
but eventually it was pointed out that the approach taken there
was just broken wrt how the uses of bonus instructions are updated
to account for the fact that they should now use either bonus instruction
or the cloned bonus instruction. In particluar, all that manual handling
of PHI nodes in successors was just wrong.

But, the fix is actually much much simpler than my initial approach:
just tell SSAUpdate about both instances of bonus instruction,
and let it deal with all the PHI handling.

Alive2 confirms that the reproducers from the original bugs (@pr48450*)
are now handled correctly.

This effectively reverts commit 59560e85897afc50090b6c3d920bacfd28b49d06,
effectively relanding b33fbbaa34f0fe9fb16789afc72ae424c1825b69.
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/CodeGen/Thumb2/mve-float16regloops.ll
llvm/test/CodeGen/Thumb2/mve-float32regloops.ll
llvm/test/CodeGen/Thumb2/mve-postinc-lsr.ll
llvm/test/Transforms/LoopUnroll/peel-loop-inner.ll
llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll