This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why so bad optimized code ?
- To: denisc at overta dot ru (Denis Chertykov)
- Subject: Re: Why so bad optimized code ?
- From: Joern Rennecke <amylaar at cambridge dot redhat dot com>
- Date: Wed, 21 Mar 2001 00:30:35 +0000 (GMT)
- Cc: gcc at gcc dot gnu dot org
> int main(void)
> {
> time->day = 5;
> time->hour= 9;
> time->min = 10;
> time->sec =10;
> }
To optimize this code, you first have to make sure that time is not aliased
by any of the dereferenced components.
We have two mechanisms that could be used to do that:
- time is a scalar and teh components are struct components with 'varying'
addresses. fixed_scalar_and_varying_struct_p should figure this out.
- (only if -fstrict-aliasing is enabled): Although the individual components
are characters, the dereference is of a structure pointer, not of a
character pointer, so I suppose the memory accesses should get non-null
alias sets.
Of course, this won't help if the optimizers just punt when they see an
intervening memory access, rather than using alias.c .
Also, AFAICR strict aliasing is currently disabled by default, so you
would have to enable to explicitly to test it.
The optimizers that I'd consider candidates for this optimizations are
gcse, cse and reload_cse.
BTW, time is not a good choice for a variable name, because there is a library
function with the same name.