diff options
author | Richard Biener <rguenther@suse.de> | 2014-06-17 07:37:24 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2014-06-17 07:37:24 +0000 |
commit | a4ab23b698ec5b8810a23df011453967d1d09180 (patch) | |
tree | 69c9a5b75cdba1ad54ff7ef330006bf5ec0f52db /gcc | |
parent | 31107d5d29e15ca7a385068b6fa09457f4cce6e1 (diff) | |
download | gcc-a4ab23b698ec5b8810a23df011453967d1d09180.zip gcc-a4ab23b698ec5b8810a23df011453967d1d09180.tar.gz gcc-a4ab23b698ec5b8810a23df011453967d1d09180.tar.bz2 |
tree-ssa-loop-im.c (determine_max_movement): Adjust cost of PHI node moving.
2014-06-17 Richard Biener <rguenther@suse.de>
* tree-ssa-loop-im.c (determine_max_movement): Adjust cost
of PHI node moving.
* gcc.dg/tree-ssa/ssa-lim-12.c: New testcase.
From-SVN: r211724
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-12.c | 27 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-im.c | 15 |
4 files changed, 47 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 676621e..16c505f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-06-17 Richard Biener <rguenther@suse.de> + + * tree-ssa-loop-im.c (determine_max_movement): Adjust cost + of PHI node moving. + 2014-06-17 Kugan Vivekanandarajah <kuganv@linaro.org> * config/arm/arm.c (arm_atomic_assign_expand_fenv): call diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d6a3dd3..7f408ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-06-17 Richard Biener <rguenther@suse.de> + + * gcc.dg/tree-ssa/ssa-lim-12.c: New testcase. + 2014-06-16 Richard Biener <rguenther@suse.de> PR tree-optimization/61482 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-12.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-12.c new file mode 100644 index 0000000..e0d93a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-12.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-lim1" } */ + +int a[1024]; + +void foo (int x, int z) +{ + int i; + int y = -x; + for (i = 0; i < 1024; ++i) + a[i] = x ? y : z; +} + +void bar (int x, int z) +{ + int j; + for (j = 0; j < 1024; ++j) + { + int i; + int y = -j + z; + for (i = 0; i < 1024; ++i) + a[i] = x ? y : j; + } +} + +/* { dg-final { scan-tree-dump-times "!= 0 ? " 2 "lim1" } } */ +/* { dg-final { cleanup-tree-dump "lim1" } } */ diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index e957f92..6569c06 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -729,14 +729,21 @@ determine_max_movement (gimple stmt, bool must_preserve_exec) } if (!add_dependency (val, lim_data, loop, false)) return false; - def_data = get_lim_data (SSA_NAME_DEF_STMT (val)); - if (def_data) + + gimple def_stmt = SSA_NAME_DEF_STMT (val); + if (gimple_bb (def_stmt) + && gimple_bb (def_stmt)->loop_father == loop) { - min_cost = MIN (min_cost, def_data->cost); - total_cost += def_data->cost; + def_data = get_lim_data (def_stmt); + if (def_data) + { + min_cost = MIN (min_cost, def_data->cost); + total_cost += def_data->cost; + } } } + min_cost = MIN (min_cost, total_cost); lim_data->cost += min_cost; if (gimple_phi_num_args (stmt) > 1) |