Subject: Re: [PATCH] x86: percpu_to_op() misses memory and flags clobbers

From: Jeremy Fitzhardinge <[email-masked]>
Date: Thu, 02 Apr 2009 07:12:30 -0700

Herbert Xu wrote:
> Jeremy Fitzhardinge <[email-masked]> wrote:
>   
>> There's probably not a lot of value in this.  The Intel and AMD 
>> optimisation guides tend to deprecate inc/dec in favour of using 
>> add/sub, because the former can cause pipeline stalls due to its partial 
>> flags update.
>>     
>
> Is this still the case on the latest Intel CPUs?
>   

Yes:

    Assembly/Compiler Coding Rule 32. (M impact, H generality) INC and DEC
    instructions should be replaced with ADD or SUB instructions,
    because ADD and
    SUB overwrite all flags, whereas INC and DEC do not, therefore
    creating false
    dependencies on earlier instructions that set the flags.

    J