This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gas/config/tc-alpha.c


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).

-- 
Michael Meissner, Cygnus Solutions, a Red Hat company.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]