]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Try to avoid lea if possible.
authorH.J. Lu <hongjiu.lu@intel.com>
Tue, 17 Aug 2010 15:49:32 +0000 (15:49 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Tue, 17 Aug 2010 15:49:32 +0000 (08:49 -0700)
2010-08-17  H.J. Lu  <hongjiu.lu@intel.com>

* config/i386/i386.c (ix86_lea_for_add_ok): For !TARGET_OPT_AGU
or optimizing for size, always avoid lea if possible.

* config/i386/i386.md (*add<mode>_1): Always avoid lea if
possible.

From-SVN: r163310

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/i386.md

index 61f3c19199e20868e5da0a2a1623f3624ae376de..47aa331abdd8a846513e8b38a7eaadf4b048b5a1 100644 (file)
@@ -1,3 +1,11 @@
+2010-08-17  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * config/i386/i386.c (ix86_lea_for_add_ok): For !TARGET_OPT_AGU
+       or optimizing for size, always avoid lea if possible.
+
+       * config/i386/i386.md (*add<mode>_1): Always avoid lea if
+       possible.
+
 2010-08-17  Iain Sandoe  <iains@gcc.gnu.org>
 
        * unwind-dw2-fde-darwin.c (_darwin10_Unwind_FindEnclosingFunction):
index b925122a32c60dd7773212306fde68f062ce5201..f1d4402b83d8209a3a9721a7d83a3fdbda8a5c57 100644 (file)
@@ -14802,10 +14802,10 @@ distance_agu_use (unsigned int regno0, rtx insn)
 #define IX86_LEA_PRIORITY 2
 
 /* Return true if it is ok to optimize an ADD operation to LEA
-   operation to avoid flag register consumation.  For the processors
-   like ATOM, if the destination register of LEA holds an actual
-   address which will be used soon, LEA is better and otherwise ADD
-   is better.  */
+   operation to avoid flag register consumation.  For most processors,
+   ADD is faster than LEA.  For the processors like ATOM, if the
+   destination register of LEA holds an actual address which will be
+   used soon, LEA is better and otherwise ADD is better.  */
 
 bool
 ix86_lea_for_add_ok (enum rtx_code code ATTRIBUTE_UNUSED,
@@ -14813,16 +14813,14 @@ ix86_lea_for_add_ok (enum rtx_code code ATTRIBUTE_UNUSED,
 {
   unsigned int regno0 = true_regnum (operands[0]);
   unsigned int regno1 = true_regnum (operands[1]);
-  unsigned int regno2;
-
-  if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun))
-    return regno0 != regno1;
-
-  regno2 = true_regnum (operands[2]);
+  unsigned int regno2 = true_regnum (operands[2]);
 
   /* If a = b + c, (a!=b && a!=c), must use lea form. */
   if (regno0 != regno1 && regno0 != regno2)
     return true;
+
+  if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun))
+    return false;
   else
     {
       int dist_define, dist_use;
index 00411583a6d52e625f36c01f5a3ec376ad5f8909..f6ab0e2f35d0eabbe2e75780184a8cf871d9d051 100644 (file)
        }
 
     default:
-      /* Use add as much as possible to replace lea for AGU optimization. */
-      if (which_alternative == 2 && TARGET_OPT_AGU)
+      /* This alternative was added for TARGET_OPT_AGU to use add as
+        much as possible.  But add is also faster than lea for
+        !TARGET_OPT_AGU.  */
+      if (which_alternative == 2)
         return "add{<imodesuffix>}\t{%1, %0|%0, %1}";
         
       gcc_assert (rtx_equal_p (operands[0], operands[1]));
     }
 }
   [(set (attr "type")
-     (cond [(and (eq_attr "alternative" "2") 
-                 (eq (symbol_ref "TARGET_OPT_AGU") (const_int 0)))
-             (const_string "lea")
-            (eq_attr "alternative" "3")
+     (cond [(eq_attr "alternative" "3")
               (const_string "lea")
            (match_operand:SWI48 2 "incdec_operand" "")
              (const_string "incdec")