Bug 65900 - gcc assembly uses wrong operand size with Intel syntax
Summary: gcc assembly uses wrong operand size with Intel syntax
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.3
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-06-03 23:12 UTC by jmbastia
Modified: 2007-04-18 16:42 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-06-04 14:21:23 UTC
Embargoed:


Attachments (Terms of Use)

Description jmbastia 2002-06-03 23:12:56 UTC
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:

Comment 1 Jakub Jelinek 2002-06-04 09:09:30 UTC
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 14:21:17 UTC
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 14:29:10 UTC
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 14:39:19 UTC
Okay.  Thanks!


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