netdev
[Top] [All Lists]

Re: [INET] Optimise away a branch in IP_ECN_set_ce

To: herbert@xxxxxxxxxxxxxxxxxxx
Subject: Re: [INET] Optimise away a branch in IP_ECN_set_ce
From: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@xxxxxxxxxxxxxx>
Date: Thu, 09 Sep 2004 10:27:36 +0900 (JST)
Cc: davem@xxxxxxxxxx, netdev@xxxxxxxxxxx, yoshfuji@xxxxxxxxxxxxxx
In-reply-to: <20040909011016.GA9238@xxxxxxxxxxxxxxxxxxx>
Organization: USAGI Project
References: <20040909000330.GA5581@xxxxxxxxxxxxxxxxxxx> <20040909.092428.125540781.yoshfuji@xxxxxxxxxxxxxx> <20040909011016.GA9238@xxxxxxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
In article <20040909011016.GA9238@xxxxxxxxxxxxxxxxxxx> (at Thu, 9 Sep 2004 
11:10:16 +1000), Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> says:

> On Thu, Sep 09, 2004 at 09:24:28AM +0900, YOSHIFUJI Hideaki / ?$B5HF#1QL@ 
> wrote:
> > 
> > s/__constant_htons/htons/g here, please.
> 
> Good point.
> 
> > And, I think 
> >   u16 ecn = (iph->tos + 1) & INET_ECN_MASK;
> >   check += (u32)htons(0xfffb) + (u32)htons(ecn);
> 
> The second htons is less optimal than the shift because htons doesn't
> know that ecn is only a byte.  So it'll end up doing a full swap.

Not true; gcc is clever enough to produces same code, and my code looks better.

-- 
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@xxxxxxxxxxxxxx>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

<Prev in Thread] Current Thread [Next in Thread>