[LoopDeletion] Fix deletion with unusual predecessor terminator (PR56266)
authorNikita Popov <npopov@redhat.com>
Fri, 1 Jul 2022 14:11:39 +0000 (16:11 +0200)
committerNikita Popov <npopov@redhat.com>
Fri, 1 Jul 2022 14:13:35 +0000 (16:13 +0200)
commit65d59b42658fdea49898c125f48f20a93de9d156
treeda6c24d6dce0f754b481bbe9cb334f3c1e37a50f
parentdc6c1f181b8a95b959f590423ce007b819532290
[LoopDeletion] Fix deletion with unusual predecessor terminator (PR56266)

LoopSimplify only requires that the loop predecessor has a single
successor and is safe to hoist into -- it doesn't necessarily have
to be an unconditional BranchInst.

Adjust LoopDeletion to assert conditions closer to what it actually
needs for correctness, namely a single successor and a
side-effect-free terminator (as the terminator is getting dropped).

Fixes https://github.com/llvm/llvm-project/issues/56266.
llvm/lib/Transforms/Utils/LoopUtils.cpp
llvm/test/Transforms/LoopDeletion/pr56266.ll [new file with mode: 0644]