This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: gas/config/tc-alpha.c
- To: Michael Meissner <meissner at cygnus dot com>
- Subject: Re: gas/config/tc-alpha.c
- From: Alan Modra <alan at linuxcare dot com dot au>
- Date: Tue, 16 May 2000 10:30:13 +1000 (EST)
- cc: binutils at sourceware dot cygnus dot com
On Mon, 15 May 2000, Michael Meissner wrote:
> On Sun, May 14, 2000 at 09:42:15PM +1000, Alan Modra wrote:
> > Is there any real reason to prefer the dangerous first form of these
> > macros?
> >
> > extract from tc-alpha.c:
> >
> > /* Macros for sign extending from 16- and 32-bits. */
> > /* XXX: The cast macros will work on all the systems that I care about,
> > but really a predicate should be found to use the non-cast forms. */
> >
> > #if 1
> > #define sign_extend_16(x) ((short)(x))
> > #define sign_extend_32(x) ((int)(x))
> > #else
> > #define sign_extend_16(x) ((offsetT)(((x) & 0xFFFF) ^ 0x8000) - 0x8000)
> > #define sign_extend_32(x) ((offsetT)(((x) & 0xFFFFFFFF) \
> > ^ 0x80000000) - 0x80000000)
> > #endif
>
> If you are worried about micro-optimizations, the first form is faster than the
> second on some platforms (in particular, if your machine does not support
> and/xor/sub of the constants in place, GCC will not re-optimize the expression
> into an appropriate sign extension).
Sure. That's why I said "any real reason" rather than "any reason". :-)
I guess it doesn't matter a great deal as binutils is riddled with this
sort of assumption about sizes of integral types. I did have some idea of
attacking the problem, but it seems a whole lot of work for little
immediate benefit.
--
Linuxcare. Support for the Revolution.