Length-Changing Prefixes problem with the x86 Backend
Nadav
nadav256@gmail.com
Wed Jun 25 21:17:00 GMT 2008
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
More information about the Gcc
mailing list