User account creation filtered due to spam.

Bug 27800 - extra temprorary created when gimplifying return
Summary: extra temprorary created when gimplifying return
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2006-05-29 18:20 UTC by Dan Nicolaescu
Modified: 2015-10-20 14:51 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2006-05-29 21:13:57


Note You need to log in before you can comment on or make changes to this bug.
Description Dan Nicolaescu 2006-05-29 18:20:37 UTC
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;
      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;
      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.
Comment 1 Dan Nicolaescu 2006-05-29 20:51:41 UTC
An even simpler example which occurs quite frequently in programs:

int jjj (int a){ return bar (a); }

jjj (a)
  int D.1891;
  int D.1892;

  D.1892 = bar (a);
  D.1891 = D.1892;
  return D.1891;
Comment 2 Andrew Pinski 2006-05-29 21:13:57 UTC