diff mbox

PATCH: PR target/50603: [x32] Unnecessary lea

Message ID 20111003230055.GA27052@intel.com
State New
Headers show

Commit Message

H.J. Lu Oct. 3, 2011, 11 p.m. UTC
This patch improves address combine for x32 by forcing the memory memory
operand of PLUS operation into register.  Tested on Linux/x86-64 with
-mx32.  OK for trunk?

Thanks.


H.J.
---
2011-10-03  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/50603
	* config/i386/i386.c (ix86_fixup_binary_operands): Force the
	memory operand of PLUS operation into register for x32.

Comments

Uros Bizjak Oct. 4, 2011, 6:17 a.m. UTC | #1
On Tue, Oct 4, 2011 at 1:00 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> This patch improves address combine for x32 by forcing the memory memory
> operand of PLUS operation into register.  Tested on Linux/x86-64 with
> -mx32.  OK for trunk?

Does the patch fix

FAIL: gcc.target/i386/pr45670.c scan-assembler-not lea[lq]

on x32 ?

Uros.
Paolo Bonzini Oct. 4, 2011, 6:56 a.m. UTC | #2
On 10/04/2011 01:00 AM, H.J. Lu wrote:
> +  else
> +    {
> +      /* Improve address combine in x32 mode.  */
> +      if (TARGET_X32
> +	&&  code == PLUS
> +	&&  !MEM_P (dst)
> +	&&  !MEM_P (src1)
> +	&&  MEM_P (src2) )
> +	src2 = force_reg (mode, src2);
> +    }

Perhaps this is worthwhile also on non-x32?

Paolo
diff mbox

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 9b079af..922f691 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -15713,6 +15713,16 @@  ix86_fixup_binary_operands (enum rtx_code code, enum machine_mode mode,
       else
 	src2 = force_reg (mode, src2);
     }
+  else
+    {
+      /* Improve address combine in x32 mode.  */
+      if (TARGET_X32
+	  && code == PLUS
+	  && !MEM_P (dst)
+	  && !MEM_P (src1)
+	  && MEM_P (src2) )
+	src2 = force_reg (mode, src2);
+    }
 
   /* If the destination is memory, and we do not have matching source
      operands, do things in registers.  */