On Tue, Oct 4, 2011 at 8:17 AM, Uros Bizjak <ubiz...@gmail.com> wrote: > On Tue, Oct 4, 2011 at 1:00 AM, H.J. Lu <hongjiu...@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 ?
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). 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; Uros.