This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

bad ASM code for short operands


Gcc 2.96 20000501 (and 2.95.2 and 1.1.2) produces bad code for this on
the i386:

----------------
static __inline void foo_short(volatile unsigned short *p, unsigned short v)
	{ __asm volatile ( "andw %2,%0" : "=m" (*p) : "0" (*p), "ir" ( ~v )); }

void bar(void) {
	unsigned short a, b;
	a = b = 1;
	foo_short(&b, a);
	return;
}
----------------

Even though `v' and `*p' are shorts (and thus 16-bits long), GCC uses the
%eax register:

    #APP
        andw %eax,(%edx)
    #NO_APP

Gas 2.9.1 ignored this discrepancy ("w" => 16-bit), but the Gas 2.10
branch version doesn't:

/var/tmp/ccD40508.s: Assembler messages:
/var/tmp/ccD40508.s:36: Warning: using `%ax' instead of `%eax' due to `w'
suffix

-- 
-- David    (obrien@NUXI.com)

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