bad ASM code for short operands
David O'Brien
obrien@NUXI.com
Thu May 4 22:56:00 GMT 2000
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)
More information about the Gcc-bugs
mailing list