]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/50962 (Additional opportunity for AGU stall avoidance optimization for...
authorEnkovich Ilya <ilya.enkovich@intel.com>
Mon, 7 Nov 2011 08:47:15 +0000 (08:47 +0000)
committerKirill Yukhin <kyukhin@gcc.gnu.org>
Mon, 7 Nov 2011 08:47:15 +0000 (08:47 +0000)
gcc/
PR target/50962
* config/i386/i386-protos.h (ix86_use_lea_for_mov): New.
* config/i386/i386.c (ix86_use_lea_for_mov): Likewise.
* config/i386/i386.md (movsi_internal): Emit lea if profitable.
(movdi_internal_rex64): Likewise.

From-SVN: r181077

gcc/config/i386/i386-protos.h
gcc/config/i386/i386.c
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog

index b2eb973355982a9eca516a30f4c07a7dfc7141af..6bfe13d47d6b529823de6dd1272417bf49f8d8c1 100644 (file)
@@ -93,6 +93,7 @@ extern bool ix86_binary_operator_ok (enum rtx_code, enum machine_mode, rtx[]);
 extern bool ix86_lea_outperforms (rtx, unsigned int, unsigned int,
                                  unsigned int, unsigned int);
 extern bool ix86_avoid_lea_for_add (rtx, rtx[]);
+extern bool ix86_use_lea_for_mov (rtx, rtx[]);
 extern bool ix86_avoid_lea_for_addr (rtx, rtx[]);
 extern void ix86_split_lea_for_addr (rtx[], enum machine_mode);
 extern bool ix86_lea_for_add_ok (rtx, rtx[]);
index ca62b229089a70ef61b41f195a495dd6717394e1..b735ab555e060ca90a503efefb34f54caebec136 100644 (file)
@@ -16509,6 +16509,29 @@ ix86_avoid_lea_for_add (rtx insn, rtx operands[])
     return !ix86_lea_outperforms (insn, regno0, regno1, regno2, 1);
 }
 
+/* Return true if we should emit lea instruction instead of mov
+   instruction.  */
+
+bool
+ix86_use_lea_for_mov (rtx insn, rtx operands[])
+{
+  unsigned int regno0;
+  unsigned int regno1;
+
+  /* Check if we need to optimize.  */
+  if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun))
+    return false;
+
+  /* Use lea for reg to reg moves only.  */
+  if (!REG_P (operands[0]) || !REG_P (operands[1]))
+    return false;
+
+  regno0 = true_regnum (operands[0]);
+  regno1 = true_regnum (operands[1]);
+
+  return ix86_lea_outperforms (insn, regno0, regno1, -1, 0);
+}
+
 /* Return true if we need to split lea into a sequence of
    instructions to avoid AGU stalls. */
 
index 39c4cd73f69e0a4ba37bbbd261723b4483799e8e..d6a82b654cd102bc2cdd7eaff61bba92aa1a8308 100644 (file)
        return "mov{l}\t{%k1, %k0|%k0, %k1}";
       else if (which_alternative == 2)
        return "movabs{q}\t{%1, %0|%0, %1}";
+      else if (ix86_use_lea_for_mov(insn, operands))
+       return "lea{q}\t{%a1, %0|%0, %a1}";
       else
        return "mov{q}\t{%1, %0|%0, %1}";
     }
 
     default:
       gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
-      return "mov{l}\t{%1, %0|%0, %1}";
+      if (ix86_use_lea_for_mov(insn, operands))
+       return "lea{l}\t{%a1, %0|%0, %a1}";
+      else
+       return "mov{l}\t{%1, %0|%0, %1}";
     }
 }
   [(set (attr "type")
index 7e7209c1d63eb4ea4947c7e65f2eb12f66a22494..66e56ee0aa5ca1427bcc7f3f4964f4e90ef99db3 100644 (file)
@@ -1,3 +1,10 @@
+2011-11-07  Enkovich Ilya  <ilya.enkovich@intel.com>
+
+       PR target/50962
+       * config/i386/i386-protos.h (ix86_use_lea_for_mov): New.
+       * config/i386/i386.c (ix86_use_lea_for_mov): Likewise.
+       * config/i386/i386.md (movsi_internal): Emit lea if profitable.
+       (movdi_internal_rex64): Likewise.
 
 2011-11-07  Sergey Ostanevich  <sergos.gnu@gmail.com>