aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-11-14 10:01:47 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-11-14 10:01:47 +0100
commitc4071191f4d20d25389181b90c0a24f254a47b87 (patch)
tree67c8f5e231a7aebefb6f2d37deeea480644fd560 /gcc
parent38e601118ca88adf0a472750b0da83f0ef1798a7 (diff)
downloadgcc-c4071191f4d20d25389181b90c0a24f254a47b87.zip
gcc-c4071191f4d20d25389181b90c0a24f254a47b87.tar.gz
gcc-c4071191f4d20d25389181b90c0a24f254a47b87.tar.bz2
re PR tree-optimization/87977 (ICE: verify_ssa failed (error: definition in block 4 follows the use))
PR tree-optimization/87977 * tree-ssa-math-opts.c (optimize_recip_sqrt): Don't reuse division stmt, build a new one and replace the old one with it. Formatting fix. Call release_ssa_name (x) if !has_other_use and !delete_div. (pass_cse_reciprocals::execute): Before calling optimize_recip_sqrt verify lhs of stmt is still def. * gcc.dg/recip_sqrt_mult_1.c: Add -fcompare-debug to dg-options. * gcc.dg/recip_sqrt_mult_2.c: Likewise. * gcc.dg/recip_sqrt_mult_3.c: Likewise. * gcc.dg/recip_sqrt_mult_4.c: Likewise. * gcc.dg/recip_sqrt_mult_5.c: Likewise. From-SVN: r266098
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c2
-rw-r--r--gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c2
-rw-r--r--gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c2
-rw-r--r--gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c2
-rw-r--r--gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c2
-rw-r--r--gcc/tree-ssa-math-opts.c13
8 files changed, 33 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 62f6383..cbd8969 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2018-11-14 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/87977
+ * tree-ssa-math-opts.c (optimize_recip_sqrt): Don't reuse division
+ stmt, build a new one and replace the old one with it. Formatting fix.
+ Call release_ssa_name (x) if !has_other_use and !delete_div.
+ (pass_cse_reciprocals::execute): Before calling optimize_recip_sqrt
+ verify lhs of stmt is still def.
+
2018-11-13 Peter Bergner <bergner@linux.ibm.com>
PR rtl-optimization/87507
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c1c92b1..eb871d0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2018-11-14 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/87977
+ * gcc.dg/recip_sqrt_mult_1.c: Add -fcompare-debug to dg-options.
+ * gcc.dg/recip_sqrt_mult_2.c: Likewise.
+ * gcc.dg/recip_sqrt_mult_3.c: Likewise.
+ * gcc.dg/recip_sqrt_mult_4.c: Likewise.
+ * gcc.dg/recip_sqrt_mult_5.c: Likewise.
+
2018-11-13 Peter Bergner <bergner@linux.ibm.com>
PR rtl-optimization/87507
diff --git a/gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c b/gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c
index 188390a..e057306 100644
--- a/gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c
+++ b/gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Ofast -fdump-tree-recip" } */
+/* { dg-options "-Ofast -fdump-tree-recip -fcompare-debug" } */
double res, res2, tmp;
void
diff --git a/gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c b/gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c
index c5fc3de..6ff284b 100644
--- a/gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c
+++ b/gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Ofast -fdump-tree-optimized" } */
+/* { dg-options "-Ofast -fdump-tree-optimized -fcompare-debug" } */
float
foo (float a)
diff --git a/gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c b/gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c
index e7d185b..7a8305d 100644
--- a/gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c
+++ b/gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Ofast -fdump-tree-optimized" } */
+/* { dg-options "-Ofast -fdump-tree-optimized -fcompare-debug" } */
double
foo (double a)
diff --git a/gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c b/gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c
index e3005f2..3b8c1ec 100644
--- a/gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c
+++ b/gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Ofast -fdump-tree-recip" } */
+/* { dg-options "-Ofast -fdump-tree-recip -fcompare-debug" } */
/* The main path doesn't have any multiplications.
Avoid introducing them in the recip pass. */
diff --git a/gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c b/gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c
index e871f0f..27c6cd2 100644
--- a/gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c
+++ b/gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Ofast -fdump-tree-recip" } */
+/* { dg-options "-Ofast -fdump-tree-recip -fcompare-debug" } */
/* We want to do the recip_sqrt transformations here there is already
a multiplication on the main path. */
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index ccff56f..d210777 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -652,8 +652,12 @@ optimize_recip_sqrt (gimple_stmt_iterator *def_gsi, tree def)
print_gimple_stmt (dump_file, stmt, 0, TDF_NONE);
fprintf (dump_file, "with new division\n");
}
- gimple_assign_set_lhs (stmt, sqr_ssa_name);
- gimple_assign_set_rhs2 (stmt, a);
+ stmt
+ = gimple_build_assign (sqr_ssa_name, gimple_assign_rhs_code (stmt),
+ gimple_assign_rhs1 (stmt), a);
+ gsi_insert_before (def_gsi, stmt, GSI_SAME_STMT);
+ gsi_remove (def_gsi, true);
+ *def_gsi = gsi_for_stmt (stmt);
fold_stmt_inplace (def_gsi);
update_stmt (stmt);
@@ -704,7 +708,7 @@ optimize_recip_sqrt (gimple_stmt_iterator *def_gsi, tree def)
gimple *new_stmt
= gimple_build_assign (x, MULT_EXPR,
- orig_sqrt_ssa_name, sqr_ssa_name);
+ orig_sqrt_ssa_name, sqr_ssa_name);
gsi_insert_after (def_gsi, new_stmt, GSI_NEW_STMT);
update_stmt (stmt);
}
@@ -715,6 +719,8 @@ optimize_recip_sqrt (gimple_stmt_iterator *def_gsi, tree def)
gsi_remove (&gsi2, true);
release_defs (stmt);
}
+ else
+ release_ssa_name (x);
}
/* Look for floating-point divisions among DEF's uses, and try to
@@ -951,6 +957,7 @@ pass_cse_reciprocals::execute (function *fun)
stmt = gsi_stmt (gsi);
if (flag_unsafe_math_optimizations
&& is_gimple_assign (stmt)
+ && gimple_assign_lhs (stmt) == def
&& !stmt_can_throw_internal (cfun, stmt)
&& gimple_assign_rhs_code (stmt) == RDIV_EXPR)
optimize_recip_sqrt (&gsi, def);