This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] PR target/23095


Hi,

See http://gcc.gnu.org/ml/gcc-patches/2005-07/msg02092.html for the
rationale for the common.opt change.  Bootstrapped on i686-pc-linux-gnu,
testing still in progress.

I'm tempted to commit this as obvious, but I'd appreciate if someone
could give it a look anyway :-)

Gr.
Steven

	PR target/23095
	* common.opt (flag_gcse_after_reload): Don't initialize to 2.
	(flag_rerun_cse_after_loop): Initialize this to 2 instead.
	* postreload-gcse.c (hash_scan_set): Do not consider stack regs.

testsuite/
	PR target/23095
	* gfortran.dg/pr23095.f: New test.

	PR c++/22003
	* g++.dg/other/pr22003.C: New test.

Index: common.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/common.opt,v
retrieving revision 1.84
diff -u -3 -p -r1.84 common.opt
--- common.opt	28 Jul 2005 21:48:22 -0000	1.84
+++ common.opt	31 Jul 2005 18:46:07 -0000
@@ -435,7 +435,7 @@ Perform redundant load after store elimi
 elimination
 
 fgcse-after-reload
-Common Report Var(flag_gcse_after_reload) Init(2)
+Common Report Var(flag_gcse_after_reload)
 Perform global common subexpression elimination after register allocation
 has finished
 
@@ -694,7 +694,7 @@ Common Report Var(flag_reorder_functions
 Reorder functions to improve code placement
 
 frerun-cse-after-loop
-Common Report Var(flag_rerun_cse_after_loop)
+Common Report Var(flag_rerun_cse_after_loop) Init(2)
 Add a common subexpression elimination pass after loop optimizations
 
 frerun-loop-opt
Index: postreload-gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/postreload-gcse.c,v
retrieving revision 2.19
diff -u -3 -p -r2.19 postreload-gcse.c
--- postreload-gcse.c	26 Jul 2005 18:47:05 -0000	2.19
+++ postreload-gcse.c	31 Jul 2005 18:46:08 -0000
@@ -745,6 +745,12 @@ hash_scan_set (rtx insn)
 	  can_copy_p (GET_MODE (dest))
 	  /* Is SET_SRC something we want to gcse?  */
 	  && general_operand (src, GET_MODE (src))
+#ifdef STACK_REGS
+	  /* Never consider insns touching the register stack.  It may
+	     create situations that reg-stack cannot handle (e.g. a stack
+	     register live across an abnormal edge).  */
+	  && REGNO (dest) < FIRST_STACK_REG && REGNO (dest) > LAST_STACK_REG
+#endif
 	  /* An expression is not available if its operands are
 	     subsequently modified, including this insn.  */
 	  && oprs_unchanged_p (src, insn, true))
@@ -759,6 +765,10 @@ hash_scan_set (rtx insn)
 	  can_copy_p (GET_MODE (src))
 	  /* Is SET_DEST something we want to gcse?  */
 	  && general_operand (dest, GET_MODE (dest))
+#ifdef STACK_REGS
+	  /* As above for STACK_REGS.  */
+	  && REGNO (src) < FIRST_STACK_REG && REGNO (src) > LAST_STACK_REG
+#endif
 	  && ! (flag_float_store && FLOAT_MODE_P (GET_MODE (dest)))
 	  /* Check if the memory expression is killed after insn.  */
 	  && ! load_killed_in_block_p (INSN_CUID (insn) + 1, dest, true)
Index: testsuite/g++.dg/other/pr22003.C
===================================================================
RCS file: testsuite/g++.dg/other/pr22003.C
diff -N testsuite/g++.dg/other/pr22003.C
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/other/pr22003.C	31 Jul 2005 18:46:12 -0000
@@ -0,0 +1,24 @@
+/* PR rtl-optimization/22003 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -freorder-blocks-and-partition" } */
+
+struct c1
+{
+      virtual ~c1();
+};
+class c4;
+
+struct c2
+{
+      virtual c4* func();
+};
+
+struct c3 : c1, c2
+{
+      c4* func();
+};
+
+c4* c3::func()
+{
+}
+
Index: testsuite/gfortran.dg/pr23095.f
===================================================================
RCS file: testsuite/gfortran.dg/pr23095.f
diff -N testsuite/gfortran.dg/pr23095.f
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gfortran.dg/pr23095.f	31 Jul 2005 18:46:17 -0000
@@ -0,0 +1,22 @@
+      ! { dg-do compile { target i?86-*-* x86_64-*-* } }
+      ! { dg-options "-w -m32 -O2 -ffloat-store -fgcse-after-reload" }
+      !
+      ! GCSE after reload made a stack register live across an abnormal
+      ! edges for one of the computed jumps.  This bombed in reg-stack.
+      function foo(n) 
+      real*8 foo 
+      integer ix, n, next 
+      real*8 xmax, absx 
+      foo  = 0.0d0 
+      assign 20 to next 
+      do ix = 1,n 
+         go to next,(10, 30) 
+   10    assign 40 to next 
+         go to 40 
+   20    if (absx .gt. 8.232d-11) go to 40 
+   30    if (absx .le. xmax) go to 40 
+         xmax = absx 
+   40    go to next,(10, 30) 
+      end do 
+      return 
+      end 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]