diff options
author | Richard Biener <rguenther@suse.de> | 2017-09-18 07:34:04 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-09-18 07:34:04 +0000 |
commit | 3d07d963f6eb6fce457e0414bef4ad428dfb7788 (patch) | |
tree | b68415e1f98470f580cf4453622870ee2dfd3c65 | |
parent | e75a0b311c372629f2bbaebae6e054ba7ca0a0e3 (diff) | |
download | gcc-3d07d963f6eb6fce457e0414bef4ad428dfb7788.zip gcc-3d07d963f6eb6fce457e0414bef4ad428dfb7788.tar.gz gcc-3d07d963f6eb6fce457e0414bef4ad428dfb7788.tar.bz2 |
re PR tree-optimization/79622 (Wrong code w/ -O2 -floop-nest-optimize)
2017-09-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/79622
* graphite-scop-detection.c (build_cross_bb_scalars_def): Properly
handle PHIs.
(build_cross_bb_scalars_use): Likewise.
* gcc.dg/graphite/pr79622.c: New testcase.
From-SVN: r252905
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/graphite-scop-detection.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/graphite/pr79622.c | 26 |
4 files changed, 46 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d357e20..d75d249 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-09-18 Richard Biener <rguenther@suse.de> + + PR tree-optimization/79622 + * graphite-scop-detection.c (build_cross_bb_scalars_def): Properly + handle PHIs. + (build_cross_bb_scalars_use): Likewise. + 2017-09-18 Pierre-Marie de Rodat <derodat@adacore.com> * cgraph.h (cgraph_thunk_info): Fix a typo in a comment. diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index bc66dfd..b209ba6 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -1744,7 +1744,9 @@ build_cross_bb_scalars_def (scop_p scop, tree def, basic_block def_bb, gimple *use_stmt; imm_use_iterator imm_iter; FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def) - if (def_bb != gimple_bb (use_stmt) && !is_gimple_debug (use_stmt)) + if ((def_bb != gimple_bb (use_stmt) && !is_gimple_debug (use_stmt)) + /* PHIs have their effect at "BBs" on the edges. See PR79622. */ + || gimple_code (SSA_NAME_DEF_STMT (def)) == GIMPLE_PHI) { writes->safe_push (def); DEBUG_PRINT (dp << "Adding scalar write: "; @@ -1758,7 +1760,8 @@ build_cross_bb_scalars_def (scop_p scop, tree def, basic_block def_bb, } } -/* Record DEF if it is used in other bbs different than DEF_BB in the SCOP. */ +/* Record USE if it is defined in other bbs different than USE_STMT + in the SCOP. */ static void build_cross_bb_scalars_use (scop_p scop, tree use, gimple *use_stmt, @@ -1774,7 +1777,9 @@ build_cross_bb_scalars_use (scop_p scop, tree use, gimple *use_stmt, return; gimple *def_stmt = SSA_NAME_DEF_STMT (use); - if (gimple_bb (def_stmt) != gimple_bb (use_stmt)) + if (gimple_bb (def_stmt) != gimple_bb (use_stmt) + /* PHIs have their effect at "BBs" on the edges. See PR79622. */ + || gimple_code (def_stmt) == GIMPLE_PHI) { DEBUG_PRINT (dp << "Adding scalar read: "; print_generic_expr (dump_file, use); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2aa605..0063c3c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-09-18 Richard Biener <rguenther@suse.de> + + PR tree-optimization/79622 + * gcc.dg/graphite/pr79622.c: New testcase. + 2017-09-17 Daniel Santos <daniel.santos@pobox.com> gcc.target/i386/pr82196-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/graphite/pr79622.c b/gcc/testsuite/gcc.dg/graphite/pr79622.c new file mode 100644 index 0000000..d71e408 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr79622.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -floop-nest-optimize" } */ + +int bf; + +int +main (void) +{ + int dc[5]; + + for (bf = 0; bf < 2; ++bf) + { + int l9, g5 = -1; + + for (l9 = 0; l9 < 5; ++l9) + { + dc[l9] = g5; + g5 = (dc[l9] > 0); + } + } + + if (dc[0] != -1) + __builtin_abort (); + + return 0; +} |