https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121762
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #3) > >BUILT_IN_UNREACHABLE -> forwprop with late set > > I am not even positive this is needed any more can be just removed. > So basically both VRP and DOM do something about this. > > DOM does it via dom_opt_dom_walker::set_global_ranges_from_unreachable_edges > . > And then VRP cleans up the edge. > > VRP does it via m_unreachable.maybe_register . > > Let me think about this and try to remove it. Here is a testcase improved by optimize_unreachable still, `-O2 -fno-tree-vrp`: ``` int foo(int a, int b, int c, int d) { if (b == a) __builtin_unreachable(); if (c == d) __builtin_unreachable(); return a > 0; } ``` -O1 works because unreachable bb is not tail merged together so rtl cfgcleanup removes the conditional. Note also the check for FORCED_LABEL is not needed in optimize_unreachable because it does NOT remove the block directly; cfgcleanup does later on if it can (with a forced label it will be moved [when removing the bb; I fixed that issue long long time ago] or the pred will be still there and the BB will NOT be removed). So at least I can do that cleanup first.