Bug 65900 - gcc assembly uses wrong operand size with Intel syntax
gcc assembly uses wrong operand size with Intel syntax
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2002-06-03 19:12 EDT by jmbastia
Modified: 2007-04-18 12:42 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-06-04 10:21:23 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description jmbastia 2002-06-03 19:12:56 EDT
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:

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:
Comment 1 Jakub Jelinek 2002-06-04 05:09:30 EDT
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).
Comment 2 jmbastia 2002-06-04 10:21:17 EDT
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.
Comment 3 Jakub Jelinek 2002-06-04 10:29:10 EDT
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.
Comment 4 jmbastia 2002-06-04 10:39:19 EDT
Okay.  Thanks!

Note You need to log in before you can comment on or make changes to this bug.