From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc2) Gecko/20020510 Description of problem: The assembly output from 'gcc -S -mintel-syntax' sometimes uses the wrong operand size. For example, this line: mov %edx, WORD PTR [%ebp-4] The WORD should be DWORD. The following program demonstrates the problem: int main(void) { short x=1, y=1, z; z = y - x; return 0; } Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. Enter above program into a text file 2. Compile with 'gcc -S -mintel-syntax' Actual Results: The line mov %edx, WORD PTR [%ebp-4] showed up in the code Expected Results: The line should have been mov %edx, DWORD PTR [%ebp-4] Additional info:
I don't see anything wrong about this. Not considering that your example actually doesn't do anything and the compiler can do on the main's stack whatever it wants if it doesn't have effects visible outside of it, if the compiler can prove that HImode variable y is aligned to 4 bytes (which it is in this case), then loading y as 4 byte word is certainly cheaper on IA-32 CPUs than loading y as 2 byte word and the effect is the same (as only %ax is used then and it is dead after).
I should have included the AT&T syntax as well. If you _don't_ use the -mintel-syntax flag, the equivalent line is: movl -4(%ebp), %edx where, of course, the 'l' suffix in AT&T is equivalent to DWORD in Intel. Also, the reason I noticed this bug is because the assembler spits out a warning: 16 0016 668B55FC mov %edx, WORD PTR [%ebp-4] **** Warning:using `%dx' instead of `%edx' due to `w' suffix So, the bug is mixing %edx with WORD.
Again, this is not present in gcc 3.1 and as -mintel-syntax (it is now -masm=intel btw) is not supported in 2.96-RH, you should just use 3.1 for intel syntax.
Okay. Thanks!