List Info

Thread: Re: Changing GCC flags for speed




Re: Changing GCC flags for <optimization>speed
country flaguser name
United States
2007-07-16 10:35:42
Chris Fairles wrote: 
> Just so we're clear, here's the descriptions of the
extra
> optimizations -O3 turns on.
> 
> -funswitch-loops
>     Move branches with loop invariant conditions out of
the loop, with
> duplicates of the loop on both branches (modified
according to result
> of the condition).
> 
> So, for example:
> 
> for i = 0 ... 100
>   if (a > 0)  f(i);
>   else g(i);
> end for
> 
> can become:
> 
> if (a > 0)
>   for i = 0..100
>     f(i)
>   end for
> else
>   for i = 0..100
>     g(i)
>   end for
> end if
> 
> It doubles code which can be an issue for embedded
platforms but
> hopefully they're using -Os anyway. I can't conjure up
a scenario
> where this might cause code to run slower.

There are lots of cases where this will run slower. Bigger
code uses
more cache space, which can mean that things you want
cached, aren't.
If the loop only runs for a few iterations, then expanding
it this way
will trade a few cheap compares for a few expensive memory
accesses.
It will also cause the program to take longer to load from
disk, which
for most programs is the main bottleneck.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

  
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )