From 1a17bd35048b702b3c5eb2ece720588a77e842c1 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 18 Oct 2012 15:46:04 +0000 Subject: [PATCH] loop-invariant.c: Include target.h. * 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 | 7 +++++++ gcc/Makefile.in | 2 +- gcc/loop-invariant.c | 18 +++++++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gnat.dg/loop_optimization13.adb | 21 +++++++++++++++++++ gcc/testsuite/gnat.dg/loop_optimization13.ads | 17 +++++++++++++++ .../gnat.dg/loop_optimization13_pkg.ads | 5 +++++ 7 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/loop_optimization13.adb create mode 100644 gcc/testsuite/gnat.dg/loop_optimization13.ads create mode 100644 gcc/testsuite/gnat.dg/loop_optimization13_pkg.ads diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c31d2566d91..146355041d7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2012-10-18 Eric Botcazou + + * 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 * except.c (sjlj_emit_function_enter): Remove unused variable. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 9376e00d992..7ae3bb9bdbc 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -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) \ diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index a420569fd43..854b41c2ed6 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9fb6e290a73..7ed81b9f5e7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-10-18 Eric Botcazou + + * gnat.dg/loop_optimization13.ad[sb]: New test. + * gnat.dg/loop_optimization13_pkg.ads: New helper. + 2012-10-18 Matthew Gretton-Dann * 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 index 00000000000..ffc516ff7ba --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization13.adb @@ -0,0 +1,21 @@ +-- { dg-do compile } +-- { dg-options "-O" } + +with Loop_Optimization13_Pkg; use Loop_Optimization13_Pkg; + +package body Loop_Optimization13 is + + function F (A : Rec) return Rec is + N : constant Integer := A.V'Length / L; + Res : Rec + := (True, new Complex_Vector' (0 .. A.V'Length / L - 1 => (0.0, 0.0))); + begin + for I in 0 .. L - 1 loop + for J in 0 .. N - 1 loop + Res.V (J) := Res.V (J) + A.V (I * N + J); + end loop; + end loop; + return Res; + end; + +end Loop_Optimization13; diff --git a/gcc/testsuite/gnat.dg/loop_optimization13.ads b/gcc/testsuite/gnat.dg/loop_optimization13.ads new file mode 100644 index 00000000000..2d3b8e59f18 --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization13.ads @@ -0,0 +1,17 @@ +with Ada.Numerics.Complex_Types; use Ada.Numerics.Complex_Types; + +package Loop_Optimization13 is + + type Complex_Vector is array (Integer range <>) of Complex; + type Complex_Vector_Ptr is access Complex_Vector; + + type Rec (Kind : Boolean := False) is record + case Kind is + when True => V : Complex_Vector_Ptr; + when False => null; + end case; + end record; + + function F (A : Rec) return Rec; + +end Loop_Optimization13; diff --git a/gcc/testsuite/gnat.dg/loop_optimization13_pkg.ads b/gcc/testsuite/gnat.dg/loop_optimization13_pkg.ads new file mode 100644 index 00000000000..8f98b6e1f12 --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization13_pkg.ads @@ -0,0 +1,5 @@ +package Loop_Optimization13_Pkg is + + L : Integer; + +end Loop_Optimization13_Pkg; -- 2.30.2