This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 2/2] [graphite] a scalar depending on vdefs in the current region is not invariant
- From: Sebastian Pop <s dot pop at samsung dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: sebpop at gmail dot com, aditya dot k7 at samsung dot com, tobias at grosser dot es, Sebastian Pop <s dot pop at samsung dot com>
- Date: Wed, 21 Oct 2015 16:04:44 -0500
- Subject: [PATCH 2/2] [graphite] a scalar depending on vdefs in the current region is not invariant
- Authentication-results: sourceware.org; auth=none
- References: <1445461484-31941-1-git-send-email-s dot pop at samsung dot com>
When a scalar is defined in function of an array reference in the current scop,
it does variate. Graphite cannot represent the condition in scop-11.c, as a[*]
variates in the current region, and it is not an affine condition:
for (j = 0; j <= 20; j++)
a[j] = b + i;
if (a[12] == 23)
b = 3;
else
b = 1;
for (j = 0; j <= 20; j++)
a[j] = b + i;
* graphite-scop-detection.c (parameter_index_in_region): Update call to
invariant_in_sese_p_rec.
* graphite-sese-to-poly.c (extract_affine): Same.
* sese.c (invariant_in_sese_p_rec): Pass in an extra parameter has_vdefs.
(scalar_evolution_in_region): Return chrec_dont_know when the scalar variable
depends on virtual definitions in the current region.
* sese.h (invariant_in_sese_p_rec): Update declaration.
testsuite/
* gcc.dg/graphite/scop-11.c: Update pattern.
---
gcc/graphite-scop-detection.c | 2 +-
gcc/graphite-sese-to-poly.c | 2 +-
gcc/sese.c | 22 ++++++++++++++++------
gcc/sese.h | 2 +-
gcc/testsuite/gcc.dg/graphite/scop-11.c | 2 +-
5 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index f425f01..e39f5b4 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1521,7 +1521,7 @@ parameter_index_in_region (tree name, sese_info_p region)
if (TREE_CODE (TREE_TYPE (name)) != INTEGER_TYPE)
return -1;
- if (!invariant_in_sese_p_rec (name, region->region))
+ if (!invariant_in_sese_p_rec (name, region->region, NULL))
return -1;
i = parameter_index_in_region_1 (name, region);
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 261e67d..8971250 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -540,7 +540,7 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space)
case SSA_NAME:
gcc_assert (-1 != parameter_index_in_region_1 (e, s->region)
- || !invariant_in_sese_p_rec (e, s->region->region));
+ || !invariant_in_sese_p_rec (e, s->region->region, NULL));
res = extract_affine_name (s, e, space);
break;
diff --git a/gcc/sese.c b/gcc/sese.c
index aa19c68..797dea5 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -787,10 +787,11 @@ set_ifsese_condition (ifsese if_region, tree condition)
}
/* Return true when T is defined outside REGION or when no definitions are
- variant in REGION. */
+ variant in REGION. When HAS_VDEFS is a valid pointer, sets HAS_VDEFS to true
+ when T depends on memory that may change in REGION. */
bool
-invariant_in_sese_p_rec (tree t, sese_l ®ion)
+invariant_in_sese_p_rec (tree t, sese_l ®ion, bool *has_vdefs)
{
ssa_op_iter iter;
use_operand_p use_p;
@@ -805,11 +806,15 @@ invariant_in_sese_p_rec (tree t, sese_l ®ion)
/* VDEF is variant when it is in the region. */
if (gimple_vdef (stmt))
- return false;
+ {
+ if (has_vdefs)
+ *has_vdefs = true;
+ return false;
+ }
/* A VUSE may or may not be variant following the VDEFs. */
if (tree vuse = gimple_vuse (stmt))
- return invariant_in_sese_p_rec (vuse, region);
+ return invariant_in_sese_p_rec (vuse, region, has_vdefs);
FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
{
@@ -818,7 +823,7 @@ invariant_in_sese_p_rec (tree t, sese_l ®ion)
if (!defined_in_sese_p (use, region))
continue;
- if (!invariant_in_sese_p_rec (use, region))
+ if (!invariant_in_sese_p_rec (use, region, has_vdefs))
return false;
}
@@ -856,8 +861,13 @@ scalar_evolution_in_region (sese_l ®ion, loop_p loop, tree t)
return t;
}
- if (invariant_in_sese_p_rec (t, region))
+ bool has_vdefs = false;
+ if (invariant_in_sese_p_rec (t, region, &has_vdefs))
return t;
+ /* T variates in REGION. */
+ if (has_vdefs)
+ return chrec_dont_know;
+
return instantiate_scev (before, loop, t);
}
diff --git a/gcc/sese.h b/gcc/sese.h
index d429d58..a428396 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -95,7 +95,7 @@ extern edge copy_bb_and_scalar_dependences (basic_block, sese_info_p, edge,
vec<tree> , bool *);
extern struct loop *outermost_loop_in_sese (sese_l &, basic_block);
extern tree scalar_evolution_in_region (sese_l &, loop_p, tree);
-extern bool invariant_in_sese_p_rec (tree, sese_l &);
+extern bool invariant_in_sese_p_rec (tree, sese_l &, bool *);
/* Check that SESE contains LOOP. */
diff --git a/gcc/testsuite/gcc.dg/graphite/scop-11.c b/gcc/testsuite/gcc.dg/graphite/scop-11.c
index 801e54f..6362003 100644
--- a/gcc/testsuite/gcc.dg/graphite/scop-11.c
+++ b/gcc/testsuite/gcc.dg/graphite/scop-11.c
@@ -19,4 +19,4 @@ int toto (int i, int b)
return a[b];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */
+/* { dg-final { scan-tree-dump-times "number of SCoPs: 0" 1 "graphite"} } */
--
1.9.1