public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Local variables optimization
@ 2005-07-24  3:52 Hanzac Chen
  2005-07-24  5:55 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Hanzac Chen @ 2005-07-24  3:52 UTC (permalink / raw)
  To: gcc

Hi,

Some idea: Maybe local stack use in the code compiled by GCC should be
optimized 'cause some local variables are conditional. If the condition
is not satisfied, then these variables don't need to be allocated from
the stack (e.g. sub $VAR_SIZE, %esp).

For example:

int *func(unsigned int cond, unsigned i)
{
   switch (cond)
   {
	case 1:
	{  int d[0x10];
	   i = memset(d, i, 0x10);
	}
	case 2:
	{  int e[0x10];
	   i = memset(e, i, 0x10);
	}
	case 3:
	{  int f[0x10];
	   i = memset(f, i, 0x10);
	}
	default:
	  break;
   }
   return 1;
}

After compiled by GCC, you'll see GCC allocated all the local variables
in case 1/case 2/case 3, this is stupid.

Hanzac

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-07-24  6:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-24  3:52 Local variables optimization Hanzac Chen
2005-07-24  5:55 ` Ian Lance Taylor
2005-07-24  6:50   ` Hanzac Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).