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

--- Comment #3 from Drea Pinski <pinskia at gcc dot gnu.org> ---
One more way of optimizing this to factor out the subtraction; that is if we
have:

  if (t_4 != 0)
    goto <bb 3>; [48.89%]
  else
    goto <bb 4>; [51.11%]

  <bb 3> [local count: 524952376]:
  _1 = .CLZ (t_4, 32);
  _5 = _1 + -1;

  <bb 4> [local count: 1073741824]:
  # _2 = PHI <_5(3), 31(2)>

This gets transformed into:

  if (t_4 != 0)
    goto <bb 3>; [48.89%]
  else
    goto <bb 4>; [51.11%]

  <bb 3> [local count: 524952376]:
  _1 = .CLZ (t_4, 32);

  <bb 4> [local count: 1073741824]:
  # _t = PHI <_1(3), 32(2)>
  _5 = _t + -1;

Which then match knows how to factor.

So if we did sccp early before say copy header, then it might work.

Reply via email to