2005-05-26 07:46:19

by cutaway

[permalink] [raw]
Subject: Re: ntfs: remove redundant assignments

---- Original Message -----
From: "Al Viro" <[email protected]>
To: "Pekka J Enberg" <[email protected]>
Cc: "Anton Altaparmakov" <[email protected]>;
<[email protected]>; <[email protected]>
Sent: Thursday, May 26, 2005 03:04
Subject: Re: ntfs: remove redundant assignments


> On Thu, May 26, 2005 at 09:21:46AM +0300, Pekka J Enberg wrote:
> > On Wed, 2005-05-25 at 22:10 +0100, Anton Altaparmakov wrote:
> > >This is not. memset(0) is not the same as = NULL IMO. I don't care if
> > >the compiler thinks it is the same. NULL does not have to be 0 so I
> > >prefer to initialize pointers explicitly to NULL. Even more so since
this
> > >code is not performance critical at all so I prefer clarity here.

FWIW, a series of explicit assignments to zero puffs up the code on x86.
Several GCC releases using the default kernel -O2 build are too dumb to zero
EAX, or some other reg, and assign using it, so you're looking at 4 bytes of
immediate zero plus opcode ModRm/SIB. If the locations being assigned
happened to be statics you can often wind up with a 10 byte instruction to
zero a single dword somewhere.

I have tried a few tricks trying to get GCC to not use this 4 byte immediate
0 in non speed critical areas all to no avail (ex. foo &= 0; the AND
instruction can use a one byte sign extended operand, but GCC morphs
something like " &= 0" into a straight up "MOV thing,imm32" instruction)