public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] phiopt: Avoid -fcompare-debug bug in phiopt [PR94211]
@ 2020-09-17 17:20 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 17:20 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:eb6097ff82a267eb4071d4f70d74cdcb57a7a638
commit eb6097ff82a267eb4071d4f70d74cdcb57a7a638
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Mar 19 10:24:16 2020 +0100
phiopt: Avoid -fcompare-debug bug in phiopt [PR94211]
Two years ago, I've added support for up to 2 simple preparation statements
in value_replacement, but the
- && estimate_num_insns (assign, &eni_time_weights)
+ && estimate_num_insns (bb_seq (middle_bb), &eni_time_weights)
change, meant that we compute the cost of all those statements rather than
just the single assign that has been the single supported non-debug
statement in the bb before, doesn't do what I thought would do, gimple_seq
is just gimple * and thus it can't be really overloaded depending on whether
we pass a single gimple * or a whole sequence. Which means in the last
two years it doesn't count all the statements, but only the first one.
With -g that happens to be a DEBUG_STMT, or it could be e.g. the first
preparation statement which could be much cheaper than the actual assign.
2020-03-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/94211
* tree-ssa-phiopt.c (value_replacement): Use estimate_num_insns_seq
instead of estimate_num_insns for bb_seq (middle_bb). Rename
emtpy_or_with_defined_p variable to empty_or_with_defined_p, adjust
all uses.
* gcc.dg/pr94211.c: New test.
(cherry picked from commit 8db876e9c045c57d2dc5bd08a6e250f822efaad0)
Diff:
---
gcc/testsuite/gcc.dg/pr94211.c | 12 ++++++++++++
gcc/tree-ssa-phiopt.c | 10 +++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/pr94211.c b/gcc/testsuite/gcc.dg/pr94211.c
new file mode 100644
index 00000000000..3e160e457fe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr94211.c
@@ -0,0 +1,12 @@
+/* PR tree-optimization/94211 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcompare-debug" } */
+
+long
+foo (long a, long b)
+{
+ if (__builtin_expect (b == 1, 1))
+ return a;
+ int e = a + 1;
+ return a / b;
+}
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 53f46dc0350..c6826cb87a2 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -890,7 +890,7 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
gimple *cond;
edge true_edge, false_edge;
enum tree_code code;
- bool emtpy_or_with_defined_p = true;
+ bool empty_or_with_defined_p = true;
/* If the type says honor signed zeros we cannot do this
optimization. */
@@ -907,7 +907,7 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
gsi_next_nondebug (&gsi);
if (!is_gimple_assign (stmt))
{
- emtpy_or_with_defined_p = false;
+ empty_or_with_defined_p = false;
continue;
}
/* Now try to adjust arg0 or arg1 according to the computation
@@ -917,7 +917,7 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
&& jump_function_from_stmt (&arg0, stmt))
|| (lhs == arg1
&& jump_function_from_stmt (&arg1, stmt)))
- emtpy_or_with_defined_p = false;
+ empty_or_with_defined_p = false;
}
cond = last_stmt (cond_bb);
@@ -969,7 +969,7 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
/* If the middle basic block was empty or is defining the
PHI arguments and this is a single phi where the args are different
for the edges e0 and e1 then we can remove the middle basic block. */
- if (emtpy_or_with_defined_p
+ if (empty_or_with_defined_p
&& single_non_singleton_phi_for_edges (phi_nodes (gimple_bb (phi)),
e0, e1) == phi)
{
@@ -1087,7 +1087,7 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
&& profile_status_for_fn (cfun) != PROFILE_ABSENT
&& EDGE_PRED (middle_bb, 0)->probability < profile_probability::even ()
/* If assign is cheap, there is no point avoiding it. */
- && estimate_num_insns (bb_seq (middle_bb), &eni_time_weights)
+ && estimate_num_insns_seq (bb_seq (middle_bb), &eni_time_weights)
>= 3 * estimate_num_insns (cond, &eni_time_weights))
return 0;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-17 17:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 17:20 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] phiopt: Avoid -fcompare-debug bug in phiopt [PR94211] Jakub Jelinek
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).