Re: [RFC] [PATCH] [timer] Optimise apply_slack() for size and speed.

From: Arjan van de Ven
Date: Fri Feb 03 2012 - 09:52:25 EST


On 2/2/2012 10:31 PM, Chinmay V S wrote:
> Here is the dis-assembly (build for x86) :
>
> Original code snippet :
> mov %eax,%ecx
> mov $0x1,%edx
> shl %cl,%edx
> sub $0x1,%edx
> mov %edx,-0x10(%ebp)
> not %edx
> and %esi,%edx
> mov %edx,-0x14(%ebp)
>
> Patched code snippet :
> mov %eax,%ecx
> shrl %cl,-0x14(%ebp)
> shll %cl,-0x14(%ebp)
>
> As is evident, we are able to reduce 5 instructions by using a bit-shift
> logic (compared to a masking logic).
>

this code is so not performance critical to this level, that we should
optimize for readability, not for the output of a compiler.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/