[Bug tree-optimization/126710] missed ifcvt optimization with clz

"pinskia at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.