diff options
author | Aditya Kumar <aditya.k7@samsung.com> | 2015-09-28 17:29:59 +0000 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2015-09-28 17:29:59 +0000 |
commit | d5b5a232d4555659943c2776d1df753e5c0387f3 (patch) | |
tree | 60998be0eae9d0a781a848fe9f960f7edde0aede | |
parent | 0a53bd6d4dc25af160c2986eb1efecd949118ad3 (diff) | |
download | gcc-d5b5a232d4555659943c2776d1df753e5c0387f3.zip gcc-d5b5a232d4555659943c2776d1df753e5c0387f3.tar.gz gcc-d5b5a232d4555659943c2776d1df753e5c0387f3.tar.bz2 |
re PR tree-optimization/67700 ([graphite] miscompile due to wrong codegen)
fix PR67700
The patch makes the detection of scop parameters in parameter_index_in_region a
bit more conservative by discarding scalar variables defined in function of data
references defined in the scop.
2015-09-25 Aditya Kumar <aditya.k7@samsung.com>
Sebastian Pop <s.pop@samsung.com>
PR tree-optimization/67700
* graphite-sese-to-poly.c (parameter_index_in_region): Call
invariant_in_sese_p_rec.
(extract_affine): Same.
(rewrite_cross_bb_scalar_deps): Call update_ssa.
* sese.c (invariant_in_sese_p_rec): Export. Handle vdefs and vuses.
* sese.h (invariant_in_sese_p_rec): Declare.
* testsuite/gcc.dg/graphite/run-id-pr67700.c: New.
Co-Authored-By: Sebastian Pop <s.pop@samsung.com>
From-SVN: r228214
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/graphite-sese-to-poly.c | 8 | ||||
-rw-r--r-- | gcc/sese.c | 14 | ||||
-rw-r--r-- | gcc/sese.h | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/graphite/run-id-pr67700.c | 36 |
6 files changed, 73 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f55f53d..b772144 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2015-09-28 Aditya Kumar <aditya.k7@samsung.com> + Sebastian Pop <s.pop@samsung.com> + + PR tree-optimization/67700 + * graphite-sese-to-poly.c (parameter_index_in_region): Call + invariant_in_sese_p_rec. + (extract_affine): Same. + (rewrite_cross_bb_scalar_deps): Call update_ssa. + * sese.c (invariant_in_sese_p_rec): Export. Handle vdefs and vuses. + * sese.h (invariant_in_sese_p_rec): Declare. + 2015-09-28 David Wohlferd <dw@LimeGreenSocks.com> * doc/extend.texi (Asm Labels): Break out text for data vs diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 09a2f91..3b8dd56 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -758,6 +758,9 @@ parameter_index_in_region (tree name, sese region) if (TREE_CODE (TREE_TYPE (name)) != INTEGER_TYPE) return -1; + if (!invariant_in_sese_p_rec (name, region)) + return -1; + i = parameter_index_in_region_1 (name, region); if (i != -1) return i; @@ -813,7 +816,8 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space) break; case SSA_NAME: - gcc_assert (-1 != parameter_index_in_region_1 (e, SCOP_REGION (s))); + gcc_assert (-1 != parameter_index_in_region_1 (e, s->region) + || !invariant_in_sese_p_rec (e, s->region)); res = extract_affine_name (s, e, space); break; @@ -2462,6 +2466,8 @@ rewrite_cross_bb_scalar_deps (scop_p scop, gimple_stmt_iterator *gsi) def, use_stmt); } + update_ssa (TODO_update_ssa); + return res; } @@ -760,9 +760,10 @@ set_ifsese_condition (ifsese if_region, tree condition) gsi_insert_after (&gsi, cond_stmt, GSI_NEW_STMT); } -/* Return false if T is completely defined outside REGION. */ +/* Return true when T is defined outside REGION or when no definitions are + variant in REGION. */ -static bool +bool invariant_in_sese_p_rec (tree t, sese region) { ssa_op_iter iter; @@ -776,9 +777,18 @@ invariant_in_sese_p_rec (tree t, sese region) || gimple_code (stmt) == GIMPLE_CALL) return false; + /* VDEF is variant when it is in the region. */ + if (tree vdef = gimple_vdef (stmt)) + 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); + FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE) { tree use = USE_FROM_PTR (use_p); + if (!defined_in_sese_p (use, region)) continue; @@ -64,6 +64,7 @@ extern edge copy_bb_and_scalar_dependences (basic_block, sese, edge, vec<tree> , bool *); extern struct loop *outermost_loop_in_sese (sese, basic_block); extern tree scalar_evolution_in_region (sese, loop_p, tree); +extern bool invariant_in_sese_p_rec (tree, sese); /* Check that SESE contains LOOP. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c2f693b..bee7aed 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-09-28 Aditya Kumar <aditya.k7@samsung.com> + Sebastian Pop <s.pop@samsung.com> + + PR tree-optimization/67700 + * testsuite/gcc.dg/graphite/run-id-pr67700.c: New. + 2015-09-28 Oleg Endo <olegendo@gcc.gnu.org> PR target/54236 diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-pr67700.c b/gcc/testsuite/gcc.dg/graphite/run-id-pr67700.c new file mode 100644 index 0000000..81d9e7f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/run-id-pr67700.c @@ -0,0 +1,36 @@ +#include <stdlib.h> +#include <assert.h> + +struct abc { + int a[81]; +} *abcd; + +#define FPMATH_SSE 2 +int global; + +void __attribute__ ((noinline)) foo() +{ + int pos = 0; + int i; + + if (!((global & FPMATH_SSE) != 0)) + for (i = 8; i <= 15; i++) + abcd->a[pos++] = i; + + for (i = 29; i <= 36; i++) + abcd->a[pos++] = i; +} + +int main() +{ + int i; + abcd = (struct abc*) malloc (sizeof (struct abc)); + for (i = 0; i <= 80; i++) + abcd->a[i] = 0; + + foo(); + + assert (abcd->a[8] == 29); + + return 0; +} |