public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8698] middle-end/101156 - remove not working optimization in gimplification
@ 2021-07-07 14:06 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-07-07 14:06 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9e1173009150086a927a6f0e001fd04c5cac54cb

commit r11-8698-g9e1173009150086a927a6f0e001fd04c5cac54cb
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jun 22 12:13:44 2021 +0200

    middle-end/101156 - remove not working optimization in gimplification
    
    This removes a premature and not working optimization from the
    gimplifier.  When gimplification is requested not to produce a SSA
    name we try to avoid generating a copy when we did so anyway but
    instead replace the LHS of its definition.  But that only works in
    case there are no uses of the SSA name already which is something
    we cannot easily check, so the following removes said optimization.
    
    Statistics on the whole bootstrap shows we hit this optimization
    only for libiberty/cp-demangle.c and overall we have 21652112
    gimplifications where just 240 copies are elided.  Preserving
    the optimization would require scanning the original expression
    and the pre and post sequences for SSA names and uses, that seems
    excessive to avoid these 240 copies.
    
    2021-06-22  Richard Biener  <rguenther@suse.de>
    
            PR middle-end/101156
            * gimplify.c (gimplify_expr): Remove premature incorrect
            optimization.
    
            * gcc.dg/pr101156.c: New testcase.
    
    (cherry picked from commit b4e21c80462682c4e6e5e487fe87107b27f8b4bd)

Diff:
---
 gcc/gimplify.c                  | 15 +--------------
 gcc/testsuite/gcc.dg/pr101156.c |  8 ++++++++
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index b65106b1459..2ac59baa8d0 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -15114,24 +15114,11 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 	       bool (*gimple_test_f) (tree), fallback_t fallback,
 	       bool allow_ssa)
 {
-  bool was_ssa_name_p = TREE_CODE (*expr_p) == SSA_NAME;
   enum gimplify_status ret = gimplify_expr (expr_p, pre_p, post_p,
 					    gimple_test_f, fallback);
   if (! allow_ssa
       && TREE_CODE (*expr_p) == SSA_NAME)
-    {
-      tree name = *expr_p;
-      if (was_ssa_name_p)
-	*expr_p = get_initialized_tmp_var (*expr_p, pre_p, NULL, false);
-      else
-	{
-	  /* Avoid the extra copy if possible.  */
-	  *expr_p = create_tmp_reg (TREE_TYPE (name));
-	  if (!gimple_nop_p (SSA_NAME_DEF_STMT (name)))
-	    gimple_set_lhs (SSA_NAME_DEF_STMT (name), *expr_p);
-	  release_ssa_name (name);
-	}
-    }
+    *expr_p = get_initialized_tmp_var (*expr_p, pre_p, NULL, false);
   return ret;
 }
 
diff --git a/gcc/testsuite/gcc.dg/pr101156.c b/gcc/testsuite/gcc.dg/pr101156.c
new file mode 100644
index 00000000000..5c25bd78a02
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101156.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-fchecking" } */
+
+struct S { int i; };
+void baz(struct S *p)
+{
+  __builtin_setjmp(p--);
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-07 14:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 14:06 [gcc r11-8698] middle-end/101156 - remove not working optimization in gimplification 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).