https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107569

--- Comment #45 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
For the #c0 foo function, one simple fix would be something like
--- gcc/passes.def.jj   2023-01-02 09:32:39.539037434 +0100
+++ gcc/passes.def      2023-03-22 16:12:57.387652639 +0100
@@ -85,6 +85,7 @@ along with GCC; see the file COPYING3.
          NEXT_PASS (pass_forwprop);
           NEXT_PASS (pass_early_thread_jumps, /*first=*/true);
          NEXT_PASS (pass_sra_early);
+         NEXT_PASS (pass_dce);
          /* pass_build_ealias is a dummy pass that ensures that we
             execute TODO_rebuild_alias at this point.  */
          NEXT_PASS (pass_build_ealias);
The problem there is that ccp1 and forwprop1 passes result in some dead
statements:
  _6 = ABS_EXPR <x_3(D)>;
  _4 = _6 u> 1.79769313486231570814527423731704356798070567525844996599e+308;
  _8 = ~_4;
  _12 = _8;
  _1 = _12;
  retval.0_5 = ~_1;
  if (retval.0_5 != 0)
by ccp1 into:
  _6 = ABS_EXPR <x_3(D)>;
  _4 = _6 u> 1.79769313486231570814527423731704356798070567525844996599e+308;
  _8 = ~_4;
  if (_4 != 0)
and forwprop1:
  _6 = ABS_EXPR <x_3(D)>;
  _4 = _6 u> 1.79769313486231570814527423731704356798070567525844996599e+308;
  _8 = ~_4;
  if (_6 u> 1.79769313486231570814527423731704356798070567525844996599e+308)
So, now both _8 and _4 setters are dead.
Then comes fre1 and happily uses them again, which results in undesirable
  _6 = ABS_EXPR <x_3(D)>;
  _4 = _6 u> 1.79769313486231570814527423731704356798070567525844996599e+308;
  _8 = ~_4;
  if (_6 u> 1.79769313486231570814527423731704356798070567525844996599e+308)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  __builtin_unreachable ();

  <bb 4> :
  return _8;
With the extra dce, we get
  _6 = ABS_EXPR <x_3(D)>;
  if (_6 u> 1.79769313486231570814527423731704356798070567525844996599e+308)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  __builtin_unreachable ();

  <bb 4> :
  _9 = ABS_EXPR <x_3(D)>;
  _10 = _9 u> 1.79769313486231570814527423731704356798070567525844996599e+308;
  _11 = ~_10;
  return _11;
before fre1 and optimize that into:
  _6 = ABS_EXPR <x_3(D)>;
  if (_6 u> 1.79769313486231570814527423731704356798070567525844996599e+308)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  __builtin_unreachable ();

  <bb 4> :
  return 1;

Reply via email to