* [PATCH] Fix debug stmt handling in optimize_recip_sqrt (PR tree-optimization/87977)
@ 2018-11-13 8:25 Jakub Jelinek
2018-11-13 9:04 ` Richard Biener
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2018-11-13 8:25 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
Hi!
During analysis, we correctly ignore debug stmt uses, but if we don't
release the ssa name we stopped using, the debug stmts uses are left in the
IL. The reset_debug_uses call is needed because the code modifies the
division stmt in place. Perhaps better would be not to do that, i.e.
create a new division and gsi_replace it, then just the release_ssa_name
would be enough and the generic code could add e.g. the 1.0 / _1 replacement
for the debug stmt? Though, in this particular case the sqrt call is
optimized away, so it wouldn't make a difference.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk, or
should I do the gimple_build_assign + gsi_replace change?
2018-11-13 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/87977
* tree-ssa-math-opts.c (optimize_recip_sqrt): Call reset_debug_uses
on stmt before changing the lhs if !has_other_use. Formatting fix.
Call release_ssa_name (x) if !has_other_use and !delete_div.
* 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.
--- gcc/tree-ssa-math-opts.c.jj 2018-10-23 10:13:22.640922226 +0200
+++ gcc/tree-ssa-math-opts.c 2018-11-12 16:55:45.468734060 +0100
@@ -652,6 +652,8 @@ optimize_recip_sqrt (gimple_stmt_iterato
print_gimple_stmt (dump_file, stmt, 0, TDF_NONE);
fprintf (dump_file, "with new division\n");
}
+ if (!has_other_use)
+ reset_debug_uses (stmt);
gimple_assign_set_lhs (stmt, sqr_ssa_name);
gimple_assign_set_rhs2 (stmt, a);
fold_stmt_inplace (def_gsi);
@@ -704,7 +706,7 @@ optimize_recip_sqrt (gimple_stmt_iterato
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 +717,8 @@ optimize_recip_sqrt (gimple_stmt_iterato
gsi_remove (&gsi2, true);
release_defs (stmt);
}
+ else
+ release_ssa_name (x);
}
/* Look for floating-point divisions among DEF's uses, and try to
--- gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c.jj 2018-09-11 18:12:24.876207127 +0200
+++ gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c 2018-11-12 16:57:53.301634244 +0100
@@ -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
--- gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c.jj 2018-09-11 18:12:24.876207127 +0200
+++ gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c 2018-11-12 16:58:01.250503686 +0100
@@ -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)
--- gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c.jj 2018-09-11 18:12:24.876207127 +0200
+++ gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c 2018-11-12 16:58:12.302322133 +0100
@@ -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)
--- gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c.jj 2018-09-11 18:12:24.877207110 +0200
+++ gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c 2018-11-12 16:58:35.748936997 +0100
@@ -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. */
--- gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c.jj 2018-09-11 18:12:24.875207143 +0200
+++ gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c 2018-11-12 16:58:41.950835127 +0100
@@ -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. */
Jakub
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix debug stmt handling in optimize_recip_sqrt (PR tree-optimization/87977)
2018-11-13 8:25 [PATCH] Fix debug stmt handling in optimize_recip_sqrt (PR tree-optimization/87977) Jakub Jelinek
@ 2018-11-13 9:04 ` Richard Biener
2018-11-13 9:19 ` Jakub Jelinek
0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2018-11-13 9:04 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Tue, 13 Nov 2018, Jakub Jelinek wrote:
> Hi!
>
> During analysis, we correctly ignore debug stmt uses, but if we don't
> release the ssa name we stopped using, the debug stmts uses are left in the
> IL. The reset_debug_uses call is needed because the code modifies the
> division stmt in place. Perhaps better would be not to do that, i.e.
> create a new division and gsi_replace it, then just the release_ssa_name
> would be enough and the generic code could add e.g. the 1.0 / _1 replacement
> for the debug stmt?
Yeah, that's how we usually deal with this. I hope the re-use of the
LHS is with the same value?
> Though, in this particular case the sqrt call is
> optimized away, so it wouldn't make a difference.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk, or
> should I do the gimple_build_assign + gsi_replace change?
I think that would be cleaner.
Richard.
> 2018-11-13 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/87977
> * tree-ssa-math-opts.c (optimize_recip_sqrt): Call reset_debug_uses
> on stmt before changing the lhs if !has_other_use. Formatting fix.
> Call release_ssa_name (x) if !has_other_use and !delete_div.
>
> * 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.
>
> --- gcc/tree-ssa-math-opts.c.jj 2018-10-23 10:13:22.640922226 +0200
> +++ gcc/tree-ssa-math-opts.c 2018-11-12 16:55:45.468734060 +0100
> @@ -652,6 +652,8 @@ optimize_recip_sqrt (gimple_stmt_iterato
> print_gimple_stmt (dump_file, stmt, 0, TDF_NONE);
> fprintf (dump_file, "with new division\n");
> }
> + if (!has_other_use)
> + reset_debug_uses (stmt);
> gimple_assign_set_lhs (stmt, sqr_ssa_name);
> gimple_assign_set_rhs2 (stmt, a);
> fold_stmt_inplace (def_gsi);
> @@ -704,7 +706,7 @@ optimize_recip_sqrt (gimple_stmt_iterato
>
> 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 +717,8 @@ optimize_recip_sqrt (gimple_stmt_iterato
> gsi_remove (&gsi2, true);
> release_defs (stmt);
> }
> + else
> + release_ssa_name (x);
> }
>
> /* Look for floating-point divisions among DEF's uses, and try to
> --- gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c.jj 2018-09-11 18:12:24.876207127 +0200
> +++ gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c 2018-11-12 16:57:53.301634244 +0100
> @@ -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
> --- gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c.jj 2018-09-11 18:12:24.876207127 +0200
> +++ gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c 2018-11-12 16:58:01.250503686 +0100
> @@ -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)
> --- gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c.jj 2018-09-11 18:12:24.876207127 +0200
> +++ gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c 2018-11-12 16:58:12.302322133 +0100
> @@ -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)
> --- gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c.jj 2018-09-11 18:12:24.877207110 +0200
> +++ gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c 2018-11-12 16:58:35.748936997 +0100
> @@ -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. */
> --- gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c.jj 2018-09-11 18:12:24.875207143 +0200
> +++ gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c 2018-11-12 16:58:41.950835127 +0100
> @@ -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. */
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix debug stmt handling in optimize_recip_sqrt (PR tree-optimization/87977)
2018-11-13 9:04 ` Richard Biener
@ 2018-11-13 9:19 ` Jakub Jelinek
2018-11-13 23:32 ` Jakub Jelinek
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2018-11-13 9:19 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
On Tue, Nov 13, 2018 at 10:04:03AM +0100, Richard Biener wrote:
> On Tue, 13 Nov 2018, Jakub Jelinek wrote:
>
> > Hi!
> >
> > During analysis, we correctly ignore debug stmt uses, but if we don't
> > release the ssa name we stopped using, the debug stmts uses are left in the
> > IL. The reset_debug_uses call is needed because the code modifies the
> > division stmt in place. Perhaps better would be not to do that, i.e.
> > create a new division and gsi_replace it, then just the release_ssa_name
> > would be enough and the generic code could add e.g. the 1.0 / _1 replacement
> > for the debug stmt?
>
> Yeah, that's how we usually deal with this. I hope the re-use of the
> LHS is with the same value?
The lhs isn't reused.
gimple_assign_set_lhs (stmt, sqr_ssa_name);
gimple_assign_set_rhs2 (stmt, a);
changes both lhs and rhs2 to some other operand. Without the
reset_debug_uses and not actually reusing the stmt we get wrong debug
info (1.0 / a), i.e. with the new rhs2, rather than old.
> > Though, in this particular case the sqrt call is
> > optimized away, so it wouldn't make a difference.
> >
> > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk, or
> > should I do the gimple_build_assign + gsi_replace change?
>
> I think that would be cleaner.
Ok, will do. Thanks.
Jakub
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix debug stmt handling in optimize_recip_sqrt (PR tree-optimization/87977)
2018-11-13 9:19 ` Jakub Jelinek
@ 2018-11-13 23:32 ` Jakub Jelinek
2018-11-14 8:22 ` Richard Biener
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2018-11-13 23:32 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
On Tue, Nov 13, 2018 at 10:19:10AM +0100, Jakub Jelinek wrote:
> > > Though, in this particular case the sqrt call is
> > > optimized away, so it wouldn't make a difference.
> > >
> > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk, or
> > > should I do the gimple_build_assign + gsi_replace change?
> >
> > I think that would be cleaner.
>
> Ok, will do. Thanks.
Here it is. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
2018-11-13 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.
* 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.
--- gcc/tree-ssa-math-opts.c.jj 2018-11-12 20:01:19.224793981 +0100
+++ gcc/tree-ssa-math-opts.c 2018-11-13 11:30:16.326203020 +0100
@@ -652,10 +652,14 @@ optimize_recip_sqrt (gimple_stmt_iterato
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);
if (dump_file)
print_gimple_stmt (dump_file, stmt, 0, TDF_NONE);
@@ -704,7 +707,7 @@ optimize_recip_sqrt (gimple_stmt_iterato
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 +718,8 @@ optimize_recip_sqrt (gimple_stmt_iterato
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 +956,7 @@ pass_cse_reciprocals::execute (function
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);
--- gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c.jj 2018-11-12 20:01:19.315792497 +0100
+++ gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c 2018-11-13 11:17:41.667541915 +0100
@@ -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
--- gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c.jj 2018-11-12 20:01:19.320792415 +0100
+++ gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c 2018-11-13 11:17:41.668541899 +0100
@@ -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)
--- gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c.jj 2018-11-12 20:01:19.363791713 +0100
+++ gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c 2018-11-13 11:17:41.671541850 +0100
@@ -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)
--- gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c.jj 2018-11-12 20:01:19.371791582 +0100
+++ gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c 2018-11-13 11:17:41.686541603 +0100
@@ -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. */
--- gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c.jj 2018-11-12 20:01:19.386791336 +0100
+++ gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c 2018-11-13 11:17:41.705541293 +0100
@@ -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. */
Jakub
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix debug stmt handling in optimize_recip_sqrt (PR tree-optimization/87977)
2018-11-13 23:32 ` Jakub Jelinek
@ 2018-11-14 8:22 ` Richard Biener
0 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2018-11-14 8:22 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Wed, 14 Nov 2018, Jakub Jelinek wrote:
> On Tue, Nov 13, 2018 at 10:19:10AM +0100, Jakub Jelinek wrote:
> > > > Though, in this particular case the sqrt call is
> > > > optimized away, so it wouldn't make a difference.
> > > >
> > > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk, or
> > > > should I do the gimple_build_assign + gsi_replace change?
> > >
> > > I think that would be cleaner.
> >
> > Ok, will do. Thanks.
>
> Here it is. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
OK.
Richard.
> 2018-11-13 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.
>
> * 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.
>
> --- gcc/tree-ssa-math-opts.c.jj 2018-11-12 20:01:19.224793981 +0100
> +++ gcc/tree-ssa-math-opts.c 2018-11-13 11:30:16.326203020 +0100
> @@ -652,10 +652,14 @@ optimize_recip_sqrt (gimple_stmt_iterato
> 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);
>
> if (dump_file)
> print_gimple_stmt (dump_file, stmt, 0, TDF_NONE);
> @@ -704,7 +707,7 @@ optimize_recip_sqrt (gimple_stmt_iterato
>
> 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 +718,8 @@ optimize_recip_sqrt (gimple_stmt_iterato
> 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 +956,7 @@ pass_cse_reciprocals::execute (function
> 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);
> --- gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c.jj 2018-11-12 20:01:19.315792497 +0100
> +++ gcc/testsuite/gcc.dg/recip_sqrt_mult_1.c 2018-11-13 11:17:41.667541915 +0100
> @@ -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
> --- gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c.jj 2018-11-12 20:01:19.320792415 +0100
> +++ gcc/testsuite/gcc.dg/recip_sqrt_mult_2.c 2018-11-13 11:17:41.668541899 +0100
> @@ -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)
> --- gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c.jj 2018-11-12 20:01:19.363791713 +0100
> +++ gcc/testsuite/gcc.dg/recip_sqrt_mult_3.c 2018-11-13 11:17:41.671541850 +0100
> @@ -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)
> --- gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c.jj 2018-11-12 20:01:19.371791582 +0100
> +++ gcc/testsuite/gcc.dg/recip_sqrt_mult_4.c 2018-11-13 11:17:41.686541603 +0100
> @@ -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. */
> --- gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c.jj 2018-11-12 20:01:19.386791336 +0100
> +++ gcc/testsuite/gcc.dg/recip_sqrt_mult_5.c 2018-11-13 11:17:41.705541293 +0100
> @@ -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. */
>
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-11-14 8:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13 8:25 [PATCH] Fix debug stmt handling in optimize_recip_sqrt (PR tree-optimization/87977) Jakub Jelinek
2018-11-13 9:04 ` Richard Biener
2018-11-13 9:19 ` Jakub Jelinek
2018-11-13 23:32 ` Jakub Jelinek
2018-11-14 8:22 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).