summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-08 11:53:27 +0000
committervries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-08 11:53:27 +0000
commit2ce3b2a5a68b424964f659ba433e4347c2bf0a06 (patch)
tree05a269611c4afd372c2778b7d951d8232bea1c84
parent2af3e910d298b2444f0114c6903fc4438a42c14a (diff)
downloadgcc-2ce3b2a5a68b424964f659ba433e4347c2bf0a06.tar.gz
Fix try_transform_to_exit_first_loop_alt
2015-06-08 Tom de Vries <tom@codesourcery.com> PR tree-optimization/66442 * gimple-iterator.h (gimple_seq_nondebug_singleton_p): Add function. * tree-parloops.c (try_transform_to_exit_first_loop_alt): Return false if the loop latch is not a singleton. Use gimple_seq_nondebug_singleton_p instead of gimple_seq_singleton_p. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224218 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/gimple-iterator.h35
-rw-r--r--gcc/tree-parloops.c4
3 files changed, 45 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c163fcb51e5..e33780fe942 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2015-06-08 Tom de Vries <tom@codesourcery.com>
+
+ PR tree-optimization/66442
+ * gimple-iterator.h (gimple_seq_nondebug_singleton_p): Add function.
+ * tree-parloops.c (try_transform_to_exit_first_loop_alt): Return false
+ if the loop latch is not a singleton. Use
+ gimple_seq_nondebug_singleton_p instead of gimple_seq_singleton_p.
+
2015-06-08 Marek Polacek <polacek@redhat.com>
PR sanitizer/66452
diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
index 87e943ae468..d08245e56ba 100644
--- a/gcc/gimple-iterator.h
+++ b/gcc/gimple-iterator.h
@@ -345,4 +345,39 @@ gsi_seq (gimple_stmt_iterator i)
return *i.seq;
}
+/* Determine whether SEQ is a nondebug singleton. */
+
+static inline bool
+gimple_seq_nondebug_singleton_p (gimple_seq seq)
+{
+ gimple_stmt_iterator gsi;
+ gsi.ptr = gimple_seq_first (seq);
+ gsi.seq = &seq;
+ gsi.bb = NULL;
+
+ /* Not a singleton if the sequence is empty. */
+ if (gsi_end_p (gsi))
+ return false;
+
+ /* Find a nondebug gimple. */
+ while (!gsi_end_p (gsi)
+ && is_gimple_debug (gsi_stmt (gsi)))
+ gsi_next (&gsi);
+
+ /* Not a nondebug singleton if there's no nondebug gimple. */
+ if (is_gimple_debug (gsi_stmt (gsi)))
+ return false;
+
+ /* Find the next nondebug gimple. */
+ while (!gsi_end_p (gsi)
+ && is_gimple_debug (gsi_stmt (gsi)))
+ gsi_next (&gsi);
+
+ /* If there's a next nondebug gimple, it's not a nondebug singleton. */
+ if (!gsi_end_p (gsi))
+ return false;
+
+ return true;
+}
+
#endif /* GCC_GIMPLE_ITERATOR_H */
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 02f44ebac74..c4b83fe9635 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -1769,8 +1769,8 @@ try_transform_to_exit_first_loop_alt (struct loop *loop,
tree nit)
{
/* Check whether the latch contains a single statement. */
- if (!gimple_seq_singleton_p (bb_seq (loop->latch)))
- return true;
+ if (!gimple_seq_nondebug_singleton_p (bb_seq (loop->latch)))
+ return false;
/* Check whether the latch contains the loop iv increment. */
edge back = single_succ_edge (loop->latch);