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

--- Comment #4 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
After the mentioned commit, e_27(D) is considered undefined, and since
_3 is [0,0], e_26 folds to [0,0] and the PHI is marked for removal:

# e_26 = PHI <e_27(D)(2), _3(13)>

However, when propagating to the uses of e_26 (replace_uses_in) here:

  if (e_26 != 0)

...value_of_expr() returns NULL, because get_non_stale_global_range()
considers the value of e_26 stale:

  if (m_globals.get_global_range (r, name))
    {
      if (m_temporal->current_p (name))
        return true;
    }

The dependencies for e_26 are e_27 and _3, per the PHI, but _3 has a
later time stamp.

The full IL follows.  Notice the interdependence between e_26 and _3.

void b ()
{
  int16_t i;
  uint64_t * f;
  uint64_t e;
  uint16_t d;
  int16_t * c;
  long unsigned int _3;
  long int d.3_5;
  short int _7;
  int a.5_8;
  int iftmp.4_11;

  <bb 2> :
  d = 2;
  // predicted unlikely by goto predictor.
  goto <bb 9>; [INV]

  <bb 3> :
  # e_25 = PHI <e_26(10)>
  _3 = e_25 + 1;
  if (_3 != 0)
    goto <bb 4>; [INV]
  else
    goto <bb 9>; [INV]

  <bb 4> :
  goto <bb 4>; [INV]

  <bb 5> :
  d.3_5 = (long int) &d;
  i_19 = (int16_t) d.3_5;
  if (i_19 != 0)
    goto <bb 6>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 6> :
  if (e_26 != 0)
    goto <bb 8>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 7> :

  <bb 8> :
  # iftmp.4_11 = PHI <1(6), 0(7)>
  _7 = (short int) iftmp.4_11;
  *c_22(D) = _7;
  goto <bb 10>; [INV]

  <bb 9> :
  # e_26 = PHI <e_27(D)(2), _3(3)>
g:

  <bb 10> :
  a.5_8 = a;
  if (a.5_8 != 0)
    goto <bb 5>; [INV]
  else
    goto <bb 3>; [INV]

}

Reply via email to