]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fix PR68976: only add loop close phi for names defined in loop
authorAditya Kumar <aditya.k7@samsung.com>
Thu, 21 Jan 2016 02:13:52 +0000 (02:13 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Thu, 21 Jan 2016 02:13:52 +0000 (02:13 +0000)
        * graphite-isl-ast-to-gimple.c: Fix comment.
        * graphite-scop-detection.c (defined_in_loop_p): New.
        (canonicalize_loop_closed_ssa): Do not add close phi nodes for SSA
        names defined in loop.

gcc/testsuite

        * gcc.dg/graphite/pr68976.c: New test.

Co-Authored-By: Sebastian Pop <s.pop@samsung.com>
From-SVN: r232658

gcc/ChangeLog
gcc/graphite-isl-ast-to-gimple.c
gcc/graphite-scop-detection.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/graphite/pr68976.c [new file with mode: 0644]

index 7e5bf1a67621a1959e7e5abf09fc6d654c8df4ab..c8232bc416e04896c9ccdf0c99798dff90a9d7b1 100644 (file)
@@ -1,3 +1,11 @@
+2016-01-21  Aditya Kumar  <aditya.k7@samsung.com>
+           Sebastian Pop  <s.pop@samsung.com>
+
+        * graphite-isl-ast-to-gimple.c: Fix comment.
+        * graphite-scop-detection.c (defined_in_loop_p): New.
+        (canonicalize_loop_closed_ssa): Do not add close phi nodes for SSA
+        names defined in loop.
+
 2016-01-21  Aditya Kumar  <aditya.k7@samsung.com>
            Sebastian Pop  <s.pop@samsung.com>
 
index 6c7fd19b76fb647e2783edd51c47ad4a8ff6f1f9..2f2daecfc05d899d494f902ec4def5d3981ed8cf 100644 (file)
@@ -507,8 +507,8 @@ private:
 /* Return the tree variable that corresponds to the given isl ast identifier
    expression (an isl_ast_expr of type isl_ast_expr_id).
 
-   FIXME: We should replace blind conversation of id's type with derivation
-   of the optimal type when we get the corresponding isl support. Blindly
+   FIXME: We should replace blind conversion of id's type with derivation
+   of the optimal type when we get the corresponding isl support.  Blindly
    converting type sizes may be problematic when we switch to smaller
    types.  */
 
index 3f268a56c37089017cfd892778235b0a77d89ff6..d026d4f56eb3a8405598d4dc4cddfe0da9ef8bf5 100644 (file)
@@ -336,6 +336,15 @@ make_close_phi_nodes_unique (basic_block bb)
     }
 }
 
+/* Return true when NAME is defined in LOOP.  */
+
+static bool
+defined_in_loop_p (tree name, loop_p loop)
+{
+  gcc_assert (TREE_CODE (name) == SSA_NAME);
+  return loop == loop_containing_stmt (SSA_NAME_DEF_STMT (name));
+}
+
 /* Transforms LOOP to the canonical loop closed SSA form.  */
 
 static void
@@ -376,7 +385,9 @@ canonicalize_loop_closed_ssa (loop_p loop)
                use_operand_p use_p;
                gphi *close_phi;
 
-               if (TREE_CODE (arg) != SSA_NAME)
+               /* Only add close phi nodes for SSA_NAMEs defined in LOOP.  */
+               if (TREE_CODE (arg) != SSA_NAME
+                   || !defined_in_loop_p (arg, loop))
                  continue;
 
                close_phi = create_phi_node (NULL_TREE, close);
index 0a2e22f0aa87c251f3c8b9eab6c2bda747646232..88774dd93a79481e5dd6e3a8e13a280c6ca75885 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-21  Aditya Kumar  <aditya.k7@samsung.com>
+           Sebastian Pop  <s.pop@samsung.com>
+
+        * gcc.dg/graphite/pr68976.c: New test.
+
 2016-01-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/67653
diff --git a/gcc/testsuite/gcc.dg/graphite/pr68976.c b/gcc/testsuite/gcc.dg/graphite/pr68976.c
new file mode 100644 (file)
index 0000000..ae9bf0f
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-options "-O2 -floop-nest-optimize" } */
+
+int kw = -1, hv = -1, ju;
+int mc[1];
+void xx(void)
+{
+  for (; kw; ++kw)
+    for (; hv; ++hv)
+      for (ju = 0; ju < 2; ++ju)
+        mc[kw+1] = mc[0];
+}