Subject: Re: [PATCH] tg3 : avoid an expensive divide

From: Andi Kleen <[email-masked]>
Date: 07 Feb 2007 10:54:49 +0100

David Miller <[email-masked]> writes:
> 
> Because I've seen gcc optimize this properly before (at least on
> sparc64), it means that either:
> 
> 1) There is a GCC bug where the properties of the constants
>    do not propagate.
> 
> 2) GCC really thinks the divide is cheaper (code density vs.
>    cycle count tradeoffs etc.)

Probably Eric compiled with the now default CONFIG_CC_OPTIMIZE_FOR_SIZE/-Os.
With that gcc decides to use the shorter hardware divide instruction, even
though it is significantly slower than an expanded optimized sequence
for constant dividend.

We've seen this in a few other cases while during performance regression
testing between kernels that still used -O2 vs the newer -Os.

No good solution found unfortunately.

-Andi