OSDN Git Service

Fix PR43097: rename only SSA_NAMEs.
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Feb 2010 12:59:17 +0000 (12:59 +0000)
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Feb 2010 12:59:17 +0000 (12:59 +0000)
2010-02-22  Sebastian Pop  <sebastian.pop@amd.com>

PR middle-end/43140
* sese.c (get_rename): Assert that old_name is an SSA_NAME.
(rename_variables_in_stmt): Continue when the use is not an SSA_NAME.

* gfortran.dg/graphite/pr43097.f: New.

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

gcc/ChangeLog.graphite
gcc/sese.c
gcc/testsuite/gfortran.dg/graphite/pr43097.f [new file with mode: 0644]

index 56b4694..aae16e7 100644 (file)
@@ -1,4 +1,12 @@
 2010-02-22  Sebastian Pop  <sebastian.pop@amd.com>
+
+       PR middle-end/43140
+       * sese.c (get_rename): Assert that old_name is an SSA_NAME.
+       (rename_variables_in_stmt): Continue when the use is not an SSA_NAME.
+
+       * gfortran.dg/graphite/pr43097.f: New.
+
+2010-02-22  Sebastian Pop  <sebastian.pop@amd.com>
            Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR middle-end/43140
index ebf9154..d7a9faa 100644 (file)
@@ -494,6 +494,7 @@ get_rename (htab_t map, tree old_name)
   struct rename_map_elt_s tmp;
   PTR *slot;
 
+  gcc_assert (TREE_CODE (old_name) == SSA_NAME);
   tmp.old_name = old_name;
   slot = htab_find_slot (map, &tmp, NO_INSERT);
 
@@ -658,14 +659,19 @@ rename_variables_in_stmt (gimple stmt, htab_t map, gimple_stmt_iterator *insert_
   FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
     {
       tree use = USE_FROM_PTR (use_p);
-      tree expr = get_rename (map, use);
-      tree type_use = TREE_TYPE (use);
-      tree type_expr = TREE_TYPE (expr);
+      tree expr, type_use, type_expr;
       gimple_seq stmts;
 
+      if (TREE_CODE (use) != SSA_NAME)
+       continue;
+
+      expr = get_rename (map, use);
       if (use == expr)
        continue;
 
+      type_use = TREE_TYPE (use);
+      type_expr = TREE_TYPE (expr);
+
       if (type_use != type_expr
          || (TREE_CODE (expr) != SSA_NAME
              && is_gimple_reg (use)))
diff --git a/gcc/testsuite/gfortran.dg/graphite/pr43097.f b/gcc/testsuite/gfortran.dg/graphite/pr43097.f
new file mode 100644 (file)
index 0000000..4ddeed8
--- /dev/null
@@ -0,0 +1,25 @@
+! { dg-options "-O2 -fgraphite-identity" }
+
+      subroutine foo (ldmx,ldmy,nx,ny,v)
+      implicit real*8 (a-h, o-z)
+      dimension v(5,ldmx,ldmy,*)
+      dimension tmat(5,5)
+
+      k = 2
+      do j = 2, ny-1
+         do i = 2, nx-1
+            do ip = 1, 4
+               do m = ip+1, 5
+                  v(m,i,j,k) = v(m,i,j,k) * m
+               end do
+            end do
+            do m = 5, 1, -1
+               do l = m+1, 5
+                  v(m,i,j,k) = v(l,i,j,k)
+               end do
+               v(m,i,j,k) = m
+           end do
+         end do
+      end do
+      return
+      end