From 4552b6fc80891c0d90c105e2040bc5ab6a2a217d Mon Sep 17 00:00:00 2001 From: ktkachov Date: Fri, 14 Sep 2018 13:13:14 +0000 Subject: [PATCH] [tree-ssa-mathopts] PR tree-optimization/87259: Call execute_cse_reciprocals_1 before trying optimize_recip_sqrt PR tree-optimization/87259 PR lto/87283 (pass_cse_reciprocals::execute): Run optimize_recip_sqrt after execute_cse_reciprocals_1 has tried transforming. PR tree-optimization/87259 * gcc.dg/pr87259.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264312 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr87259.c | 14 ++++++++++++++ gcc/tree-ssa-math-opts.c | 6 +++--- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr87259.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b5fb359c768..a9d008dea01 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-09-14 Kyrylo Tkachov + + PR tree-optimization/87259 + PR lto/87283 + (pass_cse_reciprocals::execute): Run optimize_recip_sqrt after + execute_cse_reciprocals_1 has tried transforming. + 2018-09-14 Aldy Hernandez * tree-vrp.c (extract_range_from_binary_expr_1): Normalize diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e455d898630..f6ac25f483c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-09-14 Kyrylo Tkachov + + PR tree-optimization/87259 + * gcc.dg/pr87259.c: New test. + 2018-09-13 Martin Sebor Jeff Law diff --git a/gcc/testsuite/gcc.dg/pr87259.c b/gcc/testsuite/gcc.dg/pr87259.c new file mode 100644 index 00000000000..527a60a37ad --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr87259.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ + +int a, b, c; +int *e; +float f; +void h() { + for (int g;;) { + float d = b, i = 0 / f, j = a / (f * f), k, l = 0 / d; + c = i + j; + g = l; + e[g] = c / d * k / d; + } +} diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 19bff5c3c37..e5aa5310e58 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -547,7 +547,7 @@ free_bb (struct occurrence *occ) depending on the uses of x, r1, r2. This removes one multiplication and allows the sqrt and division operations to execute in parallel. DEF_GSI is the gsi of the initial division by sqrt that defines - DEF (x in the example abovs). */ + DEF (x in the example above). */ static void optimize_recip_sqrt (gimple_stmt_iterator *def_gsi, tree def) @@ -947,13 +947,13 @@ pass_cse_reciprocals::execute (function *fun) && FLOAT_TYPE_P (TREE_TYPE (def)) && TREE_CODE (def) == SSA_NAME) { + execute_cse_reciprocals_1 (&gsi, def); + stmt = gsi_stmt (gsi); if (flag_unsafe_math_optimizations && is_gimple_assign (stmt) && !stmt_can_throw_internal (stmt) && gimple_assign_rhs_code (stmt) == RDIV_EXPR) optimize_recip_sqrt (&gsi, def); - else - execute_cse_reciprocals_1 (&gsi, def); } } -- 2.11.4.GIT