This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Length-Changing Prefixes problem with the x86 Backend
- From: Nadav <nadav256 at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 26 Jun 2008 00:16:55 +0300
- Subject: Length-Changing Prefixes problem with the x86 Backend
- References: <9b38093e0806251411if2c318cg168839f36d03743d@mail.gmail.com>
Hello,
I came across a problem with the x86 backend of gcc (3.3 - 4.1). When
I compile code which access a lookup table of size 65536, gcc
generates code which uses 16bit opcodes.
The intel architecture optimization guide warns that 16bit opcodes
should be avoided whenever possible due to Length-Changing Prefixes
(LCP). The recommendation is: ""If imm16 is needed, load equivalent
imm32 into a register and use the word value in the register instead.
""
I would expect gcc to use a 32bits register and mask it, if needed.
Even when I use 32bits registers and mask them ( & 0xFFFF), gcc
detects correctly that my variable is effectively only 16bits and it
generates 16bits code.
I modified the generated assembly to use 32bit registers and it ran much faster.
--
Cheers,
Nadav