summaryrefslogtreecommitdiff
path: root/gcc/graphite-sese-to-poly.c
diff options
context:
space:
mode:
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2010-12-16 22:54:17 +0000
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2010-12-16 22:54:17 +0000
commit935144946f2df6b447abb7c84358df4aad956892 (patch)
treea641dbfe3a54dffdf98a22c0dcc0ee96689e0352 /gcc/graphite-sese-to-poly.c
parente270313e4bf50599da0176122a282a1c31611545 (diff)
downloadgcc-935144946f2df6b447abb7c84358df4aad956892.tar.gz
Fix PR46924: Do not detect reductions outside the current SESE region.
2010-12-16 Sebastian Pop <sebastian.pop@amd.com> PR tree-optimization/46924 * graphite-sese-to-poly.c (detect_commutative_reduction): Do not detect reductions outside the current SESE region. * sese.h (stmt_in_sese_p): New. (defined_in_sese_p): Call stmt_in_sese_p. * gcc.dg/graphite/pr46924.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167962 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/graphite-sese-to-poly.c')
-rw-r--r--gcc/graphite-sese-to-poly.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 202f02861be..49250b67382 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2858,12 +2858,12 @@ initial_value_for_loop_phi (gimple phi)
return NULL_TREE;
}
-/* Detect commutative and associative scalar reductions starting at
- the loop closed phi node STMT. Return the phi node of the
- reduction cycle, or NULL. */
+/* Detect commutative and associative scalar reductions belonging to
+ the SCOP starting at the loop closed phi node STMT. Return the phi
+ node of the reduction cycle, or NULL. */
static gimple
-detect_commutative_reduction (gimple stmt, VEC (gimple, heap) **in,
+detect_commutative_reduction (scop_p scop, gimple stmt, VEC (gimple, heap) **in,
VEC (gimple, heap) **out)
{
if (scalar_close_phi_node_p (stmt))
@@ -2880,7 +2880,10 @@ detect_commutative_reduction (gimple stmt, VEC (gimple, heap) **in,
gcc_assert (gimple_phi_num_args (stmt) == 1);
def = SSA_NAME_DEF_STMT (arg);
- loop_phi = detect_commutative_reduction (def, in, out);
+ if (!stmt_in_sese_p (def, SCOP_REGION (scop)))
+ return NULL;
+
+ loop_phi = detect_commutative_reduction (scop, def, in, out);
if (loop_phi)
{
@@ -3019,7 +3022,7 @@ rewrite_commutative_reductions_out_of_ssa_close_phi (scop_p scop,
VEC (gimple, heap) *in = VEC_alloc (gimple, heap, 10);
VEC (gimple, heap) *out = VEC_alloc (gimple, heap, 10);
- detect_commutative_reduction (close_phi, &in, &out);
+ detect_commutative_reduction (scop, close_phi, &in, &out);
res = VEC_length (gimple, in) > 0;
if (res)
translate_scalar_reduction_to_array (scop, in, out);