Hello! Attached patch improves ix86_fixup_binary_operands a bit for the unlikely situation when both input operands are placed in memory. The patch forces non-matched operand 1 into register, leaving operand 2 in memory. Since x86 instruction patterns allow memory operand via operand 2, the new approach requires less fixups in reload pass.
2013-10-17 Uros Bizjak <ubiz...@gmail.com> * config/i386/i386.c (ix86_fixup_binary_operands): When both source operands are in memory, prefer to force non-matched operand 1 to the register. Patch was tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. Uros.
Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 203770) +++ config/i386/i386.c (working copy) @@ -16897,8 +16897,10 @@ ix86_fixup_binary_operands (enum rtx_code code, en src2 = force_reg (mode, src2); src1 = src2; } + else if (rtx_equal_p (dst, src1)) + src2 = force_reg (mode, src2); else - src2 = force_reg (mode, src2); + src1 = force_reg (mode, src1); } /* If the destination is memory, and we do not have matching source