Re: Recent change in tcp_output.c is surely wrong

From: Rogier Wolff (R.E.Wolff@BitWizard.nl)
Date: Tue Jan 18 2000 - 04:17:12 EST


David S. Miller wrote:

  [var = (var << 1) >> 1; ]

>
> So on Sparc there would be two options:
>
> 1) sethi %hi(0x80000000), %reg1
> andn %ato, %reg1, %result
>
> 2) sll %ato, 1, %reg1
> srl %reg1, 1, %result

David,

I agree with you on the efficiency issues. The thing is code "costs"
more in the maintenance phase than in the writing phase. So, making it
readable is important.

If you write:

#if 1
/* Clearing bit 31 is faster on some architectures if you do it this
   way. At least it isn't slower. */
#define CLEAR_BIT_31(var) var = (var << 1) >> 1
#else
/* But if you want to benchmark it, here is the classical implementation */
#define CLEAR_BIT_31(var) var &= 0x7fffffff
#endif

   var = CLEAR_BIT_31(var);

everybody knows what you are doing without having to ask you....

                                Roger.

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
 "I didn't say it was your fault. I said I was going to blame it on you."

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



This archive was generated by hypermail 2b29 : Sun Jan 23 2000 - 21:00:17 EST