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, middle-end]: Fix PR 36606; [4.4 regression] invalid rtl with -O2


Hello!

Attached patch fixes invalid RTX sharing in store_fixed_bit_field when op0 is a SUBREG rtx.

2008-04-23 Uros Bizjak <ubizjak@gmail.com>

       PR middle-end/36006
       * expmed.c (store_fixed_bit_field): Copy op0 rtx before moving
       temp to op0 in order to avoid invalid rtx sharing.

testsuite/ChangeLog:

2008-04-23 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>

       PR middle-end/36006
       * gfortran.dg/pr36006-1.f90: New test.
       * gfortran.dg/pr36006-2.f90: Ditto.

Patch was bootstrapped and regression tested on x86_64-linux-gnu. The failure is not triggered on linux, but the patch reportedly fixes reduced and original testcase on x86_64-pc-mingw32.

OK for mainline?

Uros.
Index: testsuite/gfortran.dg/pr36006-1.f90
===================================================================
--- testsuite/gfortran.dg/pr36006-1.f90	(revision 0)
+++ testsuite/gfortran.dg/pr36006-1.f90	(revision 0)
@@ -0,0 +1,23 @@
+! { dg-do compile }
+!
+subroutine test4
+  integer, parameter :: wp = 4
+  complex(wp), parameter :: i = (0._wp, 1._wp)
+  complex(wp) :: c(12)
+  integer :: m, N
+
+  N = 12
+  c = (/(exp(i*m),m=1,N)/)
+  print *, c(1)
+end
+
+subroutine test8
+  integer, parameter :: wp = 8
+  complex(wp), parameter :: i = (0._wp, 1._wp)
+  complex(wp) :: c(12)
+  integer :: m, N
+
+  N = 12
+  c = (/(exp(i*m),m=1,N)/)
+  print *, c(1)
+end
Index: testsuite/gfortran.dg/pr36006-2.f90
===================================================================
--- testsuite/gfortran.dg/pr36006-2.f90	(revision 0)
+++ testsuite/gfortran.dg/pr36006-2.f90	(revision 0)
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-require-effective-target fortran_large_real }
+!
+subroutine test_large
+  integer, parameter :: wp = selected_real_kind (precision (0.0_8) + 1)
+  complex(wp), parameter :: i = (0._wp, 1._wp)
+  complex(wp) :: c(12)
+  integer :: m, N
+
+  N = 12
+  c = (/(exp(i*m),m=1,N)/)
+  print *, c(1)
+end
Index: expmed.c
===================================================================
--- expmed.c	(revision 134600)
+++ expmed.c	(working copy)
@@ -976,7 +976,10 @@ store_fixed_bit_field (rtx op0, unsigned
     }
 
   if (op0 != temp)
-    emit_move_insn (op0, temp);
+    {
+      op0 = copy_rtx (op0);
+      emit_move_insn (op0, temp);
+    }
 }
 
 /* Store a bit field that is split across multiple accessible memory objects.

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