loop-invariant.c: Include target.h.
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 18 Oct 2012 15:46:04 +0000 (15:46 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 18 Oct 2012 15:46:04 +0000 (15:46 +0000)
* loop-invariant.c: Include target.h.
(check_dependency): Return false for an uninitialized argument register
that is likely to be spilled.
* Makefile.in (loop-invariant.o): Add $(TARGET_H).

From-SVN: r192566

gcc/ChangeLog
gcc/Makefile.in
gcc/loop-invariant.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/loop_optimization13.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/loop_optimization13.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/loop_optimization13_pkg.ads [new file with mode: 0644]

index c31d2566d91b596716e1d7f95c420b2f241959d9..146355041d70123ef0520b770f35ca95914e1928 100644 (file)
@@ -1,3 +1,10 @@
+2012-10-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * loop-invariant.c: Include target.h.
+       (check_dependency): Return false for an uninitialized argument register
+       that is likely to be spilled.
+       * Makefile.in (loop-invariant.o): Add $(TARGET_H).
+
 2012-10-18  Eric Botcazou  <ebotcazou@adacore.com>
 
        * except.c (sjlj_emit_function_enter): Remove unused variable.
index 9376e00d992df7dcc32e49e72ed7ac7857a9fa93..7ae3bb9bdbc935833f58fcbee7fbe9aeaa8c9139 100644 (file)
@@ -3101,7 +3101,7 @@ loop-iv.o : loop-iv.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h \
    intl.h $(DIAGNOSTIC_CORE_H) $(DF_H) $(HASHTAB_H)
 loop-invariant.o : loop-invariant.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h \
    $(RTL_H) $(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) $(EXPR_H) $(RECOG_H) \
-   $(TM_H) $(TM_P_H) $(FUNCTION_H) $(FLAGS_H) $(DF_H) \
+   $(TM_H) $(TM_P_H) $(FUNCTION_H) $(FLAGS_H) $(DF_H) $(TARGET_H) \
    $(OBSTACK_H) $(HASHTAB_H) $(EXCEPT_H) $(PARAMS_H) $(REGS_H) ira.h
 cfgloopmanip.o : cfgloopmanip.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) \
    $(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) \
index a420569fd43daaed07c366329e29430a4331a1bd..854b41c2ed6297ea4196091a7c9cd29e294e8c33 100644 (file)
@@ -47,6 +47,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cfgloop.h"
 #include "expr.h"
 #include "recog.h"
+#include "target.h"
 #include "function.h"
 #include "flags.h"
 #include "df.h"
@@ -784,7 +785,22 @@ check_dependency (basic_block bb, df_ref use, bitmap depends_on)
 
   defs = DF_REF_CHAIN (use);
   if (!defs)
-    return true;
+    {
+      unsigned int regno = DF_REF_REGNO (use);
+
+      /* If this is the use of an uninitialized argument register that is
+        likely to be spilled, do not move it lest this might extend its
+        lifetime and cause reload to die.  This can occur for a call to
+        a function taking complex number arguments and moving the insns
+        preparing the arguments without moving the call itself wouldn't
+        gain much in practice.  */
+      if ((DF_REF_FLAGS (use) & DF_HARD_REG_LIVE)
+         && FUNCTION_ARG_REGNO_P (regno)
+         && targetm.class_likely_spilled_p (REGNO_REG_CLASS (regno)))
+       return false;
+
+      return true;
+    }
 
   if (defs->next)
     return false;
index 9fb6e290a73ad9f2155685ec4fa153562ad4ca0d..7ed81b9f5e7a2279fb2bdae8c5b94335f2cf49b0 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/loop_optimization13.ad[sb]: New test.
+       * gnat.dg/loop_optimization13_pkg.ads: New helper.
+
 2012-10-18  Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>
 
         * gcc.target/arm/neon/vfmaQf32.c: New testcase.
diff --git a/gcc/testsuite/gnat.dg/loop_optimization13.adb b/gcc/testsuite/gnat.dg/loop_optimization13.adb
new file mode 100644 (file)
index 0000000..ffc516f
--- /dev/null
@@ -0,0 +1,21 @@
+-- { dg-do compile }\r
+-- { dg-options "-O" }\r
+\r
+with Loop_Optimization13_Pkg; use Loop_Optimization13_Pkg;\r
+\r
+package body Loop_Optimization13 is\r
+\r
+   function F (A : Rec) return Rec is\r
+      N : constant Integer := A.V'Length / L;\r
+      Res : Rec\r
+        := (True, new Complex_Vector' (0 .. A.V'Length / L - 1 => (0.0, 0.0)));\r
+   begin\r
+      for I in 0 .. L - 1 loop\r
+         for J in 0 .. N - 1 loop\r
+            Res.V (J) := Res.V (J) + A.V (I * N + J);\r
+         end loop;\r
+      end loop;\r
+      return Res;\r
+   end;\r
+\r
+end Loop_Optimization13;\r
diff --git a/gcc/testsuite/gnat.dg/loop_optimization13.ads b/gcc/testsuite/gnat.dg/loop_optimization13.ads
new file mode 100644 (file)
index 0000000..2d3b8e5
--- /dev/null
@@ -0,0 +1,17 @@
+with Ada.Numerics.Complex_Types; use Ada.Numerics.Complex_Types;\r
+\r
+package Loop_Optimization13 is\r
+\r
+   type Complex_Vector is array (Integer range <>) of Complex;\r
+   type Complex_Vector_Ptr is access Complex_Vector;\r
+\r
+   type Rec (Kind : Boolean := False) is record\r
+      case Kind is\r
+         when True => V : Complex_Vector_Ptr;\r
+         when False => null;\r
+      end case;\r
+   end record;\r
+\r
+   function F (A : Rec) return Rec;\r
+\r
+end Loop_Optimization13;\r
diff --git a/gcc/testsuite/gnat.dg/loop_optimization13_pkg.ads b/gcc/testsuite/gnat.dg/loop_optimization13_pkg.ads
new file mode 100644 (file)
index 0000000..8f98b6e
--- /dev/null
@@ -0,0 +1,5 @@
+package Loop_Optimization13_Pkg is
+
+   L : Integer;
+
+end Loop_Optimization13_Pkg;