public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix for PR62037
@ 2014-08-09  4:28 Felix Yang
  2014-08-11 11:24 ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Felix Yang @ 2014-08-09  4:28 UTC (permalink / raw)
  To: gcc-patches, dorit, irar

[-- Attachment #1: Type: text/plain, Size: 2705 bytes --]

Attached please find the patch and testcase for PR62037.

DEF1 can be a GIMPLE_NOP and gimple_bb will be NULL then. The patch
checks for that.
Bootstrapped on x86_64-suse-linux. OK for trunk? Please commit this
patch if it's OK.


Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog    (revision 213772)
+++ gcc/ChangeLog    (working copy)
@@ -1,3 +1,9 @@
+2014-08-09  Felix Yang  <fei.yang0953@gmail.com>
+
+    PR tree-optimization/62073
+    * tree-vect-loop.c (vect_is_simple_reduction_1): Check that DEF1 has
+    a basic block.
+
 2014-08-08  Guozhi Wei  <carrot@google.com>

     * config/rs6000/rs6000.md (*movdi_internal64): Add a new constraint.
Index: gcc/testsuite/gcc.dg/vect/pr62073.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/pr62073.c    (revision 0)
+++ gcc/testsuite/gcc.dg/vect/pr62073.c    (revision 0)
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -ftree-vectorize" } */
+
+struct S0
+{
+    int f7;
+};
+struct S0 g_50;
+int g_70;
+int g_76;
+
+
+int foo (long long p_56, int * p_57)
+{
+    int *l_77;
+    int l_101;
+
+    for (; g_70;)
+    {
+        int **l_78 = &l_77;
+        if (g_50.f7)
+            continue;
+        *l_78 = 0;
+    }
+    for (g_76 = 1; g_76 >= 0; g_76--)
+    {
+        int *l_90;
+        for (l_101 = 4; l_101 >= 0; l_101--)
+            if (l_101)
+                *l_90 = 0;
+            else
+            {
+                int **l_113 = &l_77;
+                *l_113 = p_57;
+            }
+    }
+
+    return *l_77;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog    (revision 213772)
+++ gcc/testsuite/ChangeLog    (working copy)
@@ -1,3 +1,8 @@
+2014-08-09  Felix Yang  <fei.yang0953@gmail.com>
+
+    PR tree-optimization/62073
+    * gcc.dg/vect/pr62073.c: New test.
+
 2014-08-08  Richard Biener  <rguenther@suse.de>

     * gcc.dg/strlenopt-8.c: Remove XFAIL.
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c    (revision 213772)
+++ gcc/tree-vect-loop.c    (working copy)
@@ -2321,7 +2321,8 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
         }

       def1 = SSA_NAME_DEF_STMT (op1);
-      if (flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))
+      if (gimple_bb (def1)
+          && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))
           && loop->inner
           && flow_bb_inside_loop_p (loop->inner, gimple_bb (def1))
           && is_gimple_assign (def1))


Cheers,
Felix

[-- Attachment #2: pr62073.diff --]
[-- Type: text/plain, Size: 2416 bytes --]

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 213772)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2014-08-09  Felix Yang  <fei.yang0953@gmail.com>
+
+	PR tree-optimization/62073
+	* tree-vect-loop.c (vect_is_simple_reduction_1): Check that DEF1 has
+	a basic block.
+
 2014-08-08  Guozhi Wei  <carrot@google.com>
 
 	* config/rs6000/rs6000.md (*movdi_internal64): Add a new constraint.
Index: gcc/testsuite/gcc.dg/vect/pr62073.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/pr62073.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/pr62073.c	(revision 0)
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -ftree-vectorize" } */
+
+struct S0
+{
+    int f7;
+};
+struct S0 g_50;
+int g_70;
+int g_76;
+
+
+int foo (long long p_56, int * p_57)
+{
+    int *l_77;
+    int l_101;
+
+    for (; g_70;)
+    {
+        int **l_78 = &l_77;
+        if (g_50.f7)
+            continue;
+        *l_78 = 0;
+    }
+    for (g_76 = 1; g_76 >= 0; g_76--)
+    {
+        int *l_90;
+        for (l_101 = 4; l_101 >= 0; l_101--)
+            if (l_101)
+                *l_90 = 0;
+            else
+            {
+                int **l_113 = &l_77;
+                *l_113 = p_57;
+            }
+    }
+
+    return *l_77;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(revision 213772)
+++ gcc/testsuite/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2014-08-09  Felix Yang  <fei.yang0953@gmail.com>
+
+	PR tree-optimization/62073
+	* gcc.dg/vect/pr62073.c: New test.
+
 2014-08-08  Richard Biener  <rguenther@suse.de>
 
 	* gcc.dg/strlenopt-8.c: Remove XFAIL.
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c	(revision 213772)
+++ gcc/tree-vect-loop.c	(working copy)
@@ -2321,7 +2321,8 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
         }
 
       def1 = SSA_NAME_DEF_STMT (op1);
-      if (flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))
+      if (gimple_bb (def1)
+          && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))
           && loop->inner
           && flow_bb_inside_loop_p (loop->inner, gimple_bb (def1))
           && is_gimple_assign (def1))

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-13 12:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-09  4:28 [PATCH] Fix for PR62037 Felix Yang
2014-08-11 11:24 ` Richard Biener
2014-08-12 16:40   ` Felix Yang
2014-08-13  9:31     ` Richard Biener
2014-08-13 12:28       ` Felix Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).