From patchwork Tue Oct 4 08:06:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: PATCH: PR target/50603: [x32] Unnecessary lea Date: Mon, 03 Oct 2011 22:06:23 -0000 From: Uros Bizjak X-Patchwork-Id: 117587 Message-Id: To: "H.J. Lu" Cc: gcc-patches@gcc.gnu.org On Tue, Oct 4, 2011 at 8:17 AM, Uros Bizjak wrote: > On Tue, Oct 4, 2011 at 1:00 AM, H.J. Lu 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 ? It does. Following patch is the same, but takes into account that non-matching memory can only be in src2, so it avoids a bunch of unnecessary checks. Can you please check the effects of the patch with some codesize benchmark? Please also add the test from the PR that checks for lea (similar to pr45670.c test). Uros. Index: i386.c =================================================================== --- i386.c (revision 179489) +++ i386.c (working copy) @@ -15727,6 +15727,10 @@ if (MEM_P (src1) && !rtx_equal_p (dst, src1)) src1 = force_reg (mode, src1); + /* Improve address combine in x32 mode. */ + if (TARGET_X32 && code == PLUS && MEM_P (src2)) + src2 = force_reg (mode, src2); + operands[1] = src1; operands[2] = src2; return dst;