i386 assembler issue?

Alan Modra alan@linuxcare.com.au
Thu Apr 27 18:24:00 GMT 2000


On Thu, 27 Apr 2000, Jeffrey A Law wrote:

> I'm not an ia32 guru, but it seems to me that if there's a more
> efficient way to encode left-shift by 1, then the assembler should
> use it.

The smaller opcode is apparently slower on a 486.  Here's the relevant
code in gas/config/tc-i386.c

static int
smallest_imm_type (num)
     offsetT num;
{
#if 0
  /* This code is disabled because all the Imm1 forms in the opcode table
     are slower on the i486, and they're the versions with the implicitly
     specified single-position displacement, which has another syntax if
     you really want to use that form.  If you really prefer to have the
     one-byte-shorter Imm1 form despite these problems, re-enable this
     code.  */
  if (num == 1)
    return Imm1 | Imm8 | Imm8S | Imm16 | Imm32;
#endif

I checked a pentium manual, and there isn't any difference in speed on
586, and I assume that's the case for more recent processors too.  I'm not
against re-enabling this code, since 486 is getting fairly old, but I'd
like someone to check that there isn't some pairing problem or other issue
on newer processors.  cc'd back to gcc-bugs in hope of interesting Ulrich
or other x86 optimisation gurus :-)

-- 
Linuxcare.  Support for the Revolution.





More information about the Gcc-bugs mailing list