OSDN Git Service

PR rtl-optimization/38722
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Jan 2009 20:41:52 +0000 (20:41 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Jan 2009 20:41:52 +0000 (20:41 +0000)
* combine.c (try_combine): Don't modify PATTERN (i3) and notes
too early, only set a flag and modify after last possible
undo_all point.

* gfortran.dg/pr38722.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143132 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr38722.f90 [new file with mode: 0644]

index 80fd4d0..8dafe63 100644 (file)
@@ -1,3 +1,10 @@
+2009-01-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/38722
+       * combine.c (try_combine): Don't modify PATTERN (i3) and notes
+       too early, only set a flag and modify after last possible
+       undo_all point.
+
 2009-01-06  Janis Johnson  <janis187@us.ibm.com>
 
        PR c/34252
 2009-01-06  Janis Johnson  <janis187@us.ibm.com>
 
        PR c/34252
index d6f7480..0198342 100644 (file)
@@ -1,6 +1,6 @@
 /* Optimize by combining instructions for GNU compiler.
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
 /* Optimize by combining instructions for GNU compiler.
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
 This file is part of GCC.
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -2208,6 +2208,7 @@ try_combine (rtx i3, rtx i2, rtx i1, int *new_direct_jump_p)
   /* Notes that I1, I2 or I3 is a MULT operation.  */
   int have_mult = 0;
   int swap_i2i3 = 0;
   /* Notes that I1, I2 or I3 is a MULT operation.  */
   int have_mult = 0;
   int swap_i2i3 = 0;
+  int changed_i3_dest = 0;
 
   int maxreg;
   rtx temp;
 
   int maxreg;
   rtx temp;
@@ -2895,14 +2896,7 @@ try_combine (rtx i3, rtx i2, rtx i1, int *new_direct_jump_p)
          insn_code_number = recog_for_combine (&newpat, i3, &new_i3_notes);
 
          if (insn_code_number >= 0)
          insn_code_number = recog_for_combine (&newpat, i3, &new_i3_notes);
 
          if (insn_code_number >= 0)
-           {
-             /* If we will be able to accept this, we have made a
-                change to the destination of I3.  This requires us to
-                do a few adjustments.  */
-
-             PATTERN (i3) = newpat;
-             adjust_for_new_dest (i3);
-           }
+           changed_i3_dest = 1;
        }
     }
 
        }
     }
 
@@ -3375,6 +3369,16 @@ try_combine (rtx i3, rtx i2, rtx i1, int *new_direct_jump_p)
       return 0;
     }
 
       return 0;
     }
 
+  /* If we will be able to accept this, we have made a
+     change to the destination of I3.  This requires us to
+     do a few adjustments.  */
+
+  if (changed_i3_dest)
+    {
+      PATTERN (i3) = newpat;
+      adjust_for_new_dest (i3);
+    }
+
   /* We now know that we can do this combination.  Merge the insns and
      update the status of registers and LOG_LINKS.  */
 
   /* We now know that we can do this combination.  Merge the insns and
      update the status of registers and LOG_LINKS.  */
 
index 07c2de1..5d7c49d 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/38722
+       * gfortran.dg/pr38722.f90: New test.
+
 2009-01-06  Janis Johnson  <janis187@us.ibm.com>
 
        PR c/34252
 2009-01-06  Janis Johnson  <janis187@us.ibm.com>
 
        PR c/34252
diff --git a/gcc/testsuite/gfortran.dg/pr38722.f90 b/gcc/testsuite/gfortran.dg/pr38722.f90
new file mode 100644 (file)
index 0000000..7a4f63e
--- /dev/null
@@ -0,0 +1,38 @@
+! PR rtl-optimization/38722
+! { dg-do compile }
+! { dg-options "-O1" }
+SUBROUTINE foo(x, n, ga, gc, vr)
+  TYPE pt
+    DOUBLE PRECISION, DIMENSION (:, :, :), POINTER :: cr
+  END TYPE pt
+  TYPE pu
+    TYPE(pt), POINTER :: pw
+  END TYPE pu
+  LOGICAL, INTENT(in) :: x, ga, gc
+  INTEGER :: i, n
+  LOGICAL :: dd, ep, fe
+  TYPE(pu) :: vr
+  TYPE(pu), DIMENSION(:), POINTER :: v
+  IF (.NOT. fe) THEN
+     IF (ga) THEN
+        CALL bar (dd, ep, gc)
+     END IF
+     IF (x .AND. .NOT. ga) THEN
+        IF (gc) THEN
+          DO i=1,n
+            CALL baz (v(i), x, gc)
+            v(i)%pw%cr = 1.0
+          END DO
+          DO i=1,n
+             IF (ep) THEN
+                IF (dd) THEN
+                   IF (i==1) THEN
+                      v(i)%pw%cr=v(i)%pw%cr + vr%pw%cr
+                   ENDIF
+                END IF
+             END IF
+          END DO
+        END IF
+     ENDIF
+  END IF
+END SUBROUTINE foo