Commit 60ba7cd3 by H.J. Lu

x32: Encode %esp as %rsp to avoid 0x67 prefix

Since the upper 32 bits of stack register are always zero for x32, we
can encode %esp as %rsp to avoid 0x67 prefix in address if there is no
index or base register.

gcc/

	PR target/82267
	* config/i386/i386.c (ix86_print_operand_address_as): Encode
	%esp as %rsp to avoid 0x67 prefix if there is no index or base
	register.

gcc/testsuite/

	PR target/82267
	* gcc.target/i386/pr82267.c: New test.

From-SVN: r253127
parent c6c74708
2017-09-24 Uros Bizjak <ubizjak@gmail.com>
PR target/82267
* config/i386/i386.c (ix86_print_operand_address_as): Encode
%esp as %rsp to avoid 0x67 prefix if there is no index or base
register.
2017-09-23 Uros Bizjak <ubizjak@gmail.com> 2017-09-23 Uros Bizjak <ubizjak@gmail.com>
PR bootstrap/82306 PR bootstrap/82306
...@@ -19953,6 +19953,14 @@ ix86_print_operand_address_as (FILE *file, rtx addr, ...@@ -19953,6 +19953,14 @@ ix86_print_operand_address_as (FILE *file, rtx addr,
code = 'k'; code = 'k';
} }
/* Since the upper 32 bits of RSP are always zero for x32, we can
encode %esp as %rsp to avoid 0x67 prefix if there is no index or
base register. */
if (TARGET_X32 && Pmode == SImode
&& ((!index && base && REGNO (base) == SP_REG)
|| (!base && index && REGNO (index) == SP_REG)))
code = 'q';
if (ASSEMBLER_DIALECT == ASM_ATT) if (ASSEMBLER_DIALECT == ASM_ATT)
{ {
if (disp) if (disp)
2017-09-24 H.J. Lu <hongjiu.lu@intel.com>
PR target/82267
* gcc.target/i386/pr82267.c: New test.
2017-09-24 Thomas Koenig <tkoenig@gcc.gnu.org> 2017-09-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/66328 PR fortran/66328
......
/* { dg-do compile { target { ! ia32 } } } */
/* { dg-require-effective-target maybe_x32 } */
/* { dg-options "-O2 -mx32 -maddress-mode=short" } */
int
stackuse (void)
{
volatile int foo = 2;
return foo * 3;
}
/* Verify we that use %rsp to access stack. */
/* { dg-final { scan-assembler-not "%esp" } } */
/* { dg-final { scan-assembler "%rsp" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment