One would think that the temporaries created when gimplifying the following
2 functions would be the same:

void hhh (int a, int b, int c){ bar (a?b:c); }
int iii (int a, int b, int c){ return (a?b:c); }

But they are not:

hhh (a, b, c)
{
  int iftmp.0;
  if (a != 0)
    {
      iftmp.0 = b;
    }
  else
    {
      iftmp.0 = c;
    }
  bar (iftmp.0);
}

This one is fine. 
But this one:

iii (a, b, c)
{
  int D.2128;
  int iftmp.1;
  if (a != 0)
    {
      iftmp.1 = b;
    }
  else
    {
      iftmp.1 = c;
    }
  D.2128 = iftmp.1;
  return D.2128;
}
creates an extra temporary for the return expression. It would be more memory
efficient if it would just use "iftmp.1" as the first function does.


-- 
           Summary: extra temprorary created when gimplifying return
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dann at godzilla dot ics dot uci dot edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27800

Reply via email to