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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmpf.  So the following was not optimized ever:

void foo (void);
void bar (void);

int
test (int a)
{
  int r = -a;

  if (a == 0)
    foo ();
  else
    bar ();

  return r;
}

Note this is also about canonicalization if you consider both jump forms
appearing in the source and the ability to thread them.

But yes, the CC re-using form is better (in case r is not dead otherwise).

On GIMPLE this shows we lack modeling of CCs.  I'm not sure doing

 _1 = __IFN_NEGATE_WITH_CCZ (a_2);
 r_3 = __real _1;
 _4 = __imag _1;
 if (_4 != 0)
   foo ();
 else
   bar ();

is the way to go though (that would be possible with current infrastructure).
A "nicer"/leaner way would be to generalize SSA projections so we do not
have to abuse COMPLEX and could allow

 _1 = __IFN_NEGATE_WITH_CC (a_2);
 r_3 = __value _1;
 if (__CCZ _1 != 0);
   foo ();
 else
   bar ();

but then doing this on GIMPLE is of course prone to CC spilling.

Note "fixing" the above testcase on GIMPLE is as hard as fixing it on RTL.

Reply via email to