[Bug tree-optimization/91459] Tail-Call Optimization is not performed when return value is assumed.

2019-08-16 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91459

--- Comment #3 from Andrew Pinski  ---
Part of that might be because of:
  // predicted unlikely by early return (on trees) predictor.

That seems not true, the other side is more unlikely ...

[Bug tree-optimization/91459] Tail-Call Optimization is not performed when return value is assumed.

2019-08-16 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91459

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-08-16
  Component|middle-end  |tree-optimization
 Ever confirmed|0   |1

--- Comment #2 from Richard Biener  ---
I think this has a duplicate somewhere.  The reason is we end up with

foo1 (int a, int b)
{
   [local count: 1073741824]:
  function_returns_only_1_or_doesnt_return (a_2(D), b_3(D));
  return 1;

and thus no obvious tail-call opportunity.  Here it is EVRP replacing
result_5 with 1 in

   :
  result_5 = function_returns_only_1_or_doesnt_return (a_2(D), b_3(D));
  if (result_5 == 1)
goto ; [INV]
  else
goto ; [INV]

   :
  // predicted unlikely by early return (on trees) predictor.
  return result_5;

   :
  __builtin_unreachable ();

where it would be better to transform this idiom to unconditional
return result_5 early.