This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Why so bad optimized code ?


> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]