From: Richard Biener Date: Tue, 17 Jun 2014 07:37:24 +0000 (+0000) Subject: tree-ssa-loop-im.c (determine_max_movement): Adjust cost of PHI node moving. X-Git-Tag: releases/gcc-5.1.0~6833 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a4ab23b698ec5b8810a23df011453967d1d09180;p=thirdparty%2Fgcc.git tree-ssa-loop-im.c (determine_max_movement): Adjust cost of PHI node moving. 2014-06-17 Richard Biener * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 676621e85cf0..16c505f6f1d9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-06-17 Richard Biener + + * tree-ssa-loop-im.c (determine_max_movement): Adjust cost + of PHI node moving. + 2014-06-17 Kugan Vivekanandarajah * config/arm/arm.c (arm_atomic_assign_expand_fenv): call diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d6a3dd3c7e0c..7f408adf7439 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-06-17 Richard Biener + + * gcc.dg/tree-ssa/ssa-lim-12.c: New testcase. + 2014-06-16 Richard Biener 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 000000000000..e0d93a993d24 --- /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 e957f9211415..6569c0664d26 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)