Subject: Re: Intermediate void* casts
To: Bill Studenmund <wrstuden@netbsd.org>
From: Martin Husemann <martin@duskware.de>
List: tech-misc
Date: 08/11/2003 10:31:35
[note: tech-misc only]

On Sun, Aug 10, 2003 at 05:15:43PM -0700, Bill Studenmund wrote:

> Though what exactly is an alias bug?

IIUC (see my followup to Manuel on tech-misc): modifying the value of an
object via a lvalue not conforming to the rules stated in the C standard (that
I already quoted in that other message).

> I'm not so sure about that. Can/will the compiler notice that you're only
> using half of a 64-bit value? Otherwise, by making this change, you're
> pulling in more 64-bit using code. For sparc64 that's not bad, since the
> registers are 64-bit. But for sparc, 64-bit values won't fit in a
> register, and so manipulating them can be cumbersome.

Yeah, the code for bswap64 now has two versions, #ifdef _LP64.
If gcc does miss the obvious, the 32bit code might be slightly slower
than the old code. I can't test that right now, anyone with i386 gcc 3.3.1
around? If the value is spread accross two 32 bit registers, and the code
accesses one half of it via shift and mask with constants, I expect the 
compiler to notice and just use the right register without any operations.

> Yes, I realize that if we're talking about a 64-bit value, other bits of
> code are having to deal with the difficulties of 64-bit math & such. But
> if there's a place where we can make the code more efficient than the
> compiler will on its own, I think we should.

Agreed - that's why it needs manual investigation.

Martin