On 9/19/25 13:45, Andrew Pinski wrote:
Since optimize_unreachable does not directly remove the bb, we can still remove
the condition that goes to a block containing a forced label. This is a small
cleanup
from the original patch which added optimize_unreachable.
The review of the original patch missed that the bb was not being removed by
the pass
but later on by cleanupcfg;
https://gcc.gnu.org/pipermail/gcc-patches/2012-July/343239.html.
Which is why this is allowed to be done.
I added another testcase to check that the `if` is removed too.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-ccp.cc (optimize_unreachable): Don't check for forced labels.
gcc/testsuite/ChangeLog:
* gcc.dg/builtin-unreachable-7.c: New test.
I guess ultimately this isn't intersecting with the need to preserve
instructions with side effects before the unreachable, it's just about
detecting more cases where we can remove the controlling conditional.
We still have to emit the forced label. Conceptually since it's
reaching a builtin_unreachable we can emit it anywhere that's convenient
as traversing into that code implies undefined behavior of some kind.
Assuming that's the case. OK for the trunk.
jeff