public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-129] tree-optimization/105484 - VEC_SET and EH
@ 2022-05-05  8:37 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-05-05  8:37 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e1a41143a2e24c65d94364fd82b165ff71a759d8

commit r13-129-ge1a41143a2e24c65d94364fd82b165ff71a759d8
Author: Richard Biener <rguenther@suse.de>
Date:   Thu May 5 09:34:59 2022 +0200

    tree-optimization/105484 - VEC_SET and EH
    
    When the IL representation of VEC_SET is marked as throwing
    (unnecessarily), we need to clean that when replacing it with
    the .VEC_SET internal function call which cannot throw.
    
    2022-05-05  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/105484
            * gimple-isel.cc (gimple_expand_vec_set_expr): Clean EH, return
            whether the CFG changed.
            (gimple_expand_vec_exprs): When the CFG changed, clean it up.
    
            * gcc.dg/torture/pr105484.c: New testcase.

Diff:
---
 gcc/gimple-isel.cc                      | 19 ++++++++++++-------
 gcc/testsuite/gcc.dg/torture/pr105484.c | 15 +++++++++++++++
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc
index a8f7a0d25d0..4b309a05a9a 100644
--- a/gcc/gimple-isel.cc
+++ b/gcc/gimple-isel.cc
@@ -49,22 +49,23 @@ along with GCC; see the file COPYING3.  If not see
      _8 = .VEC_SET (_7, i_4(D), _1);
      u = _8;  */
 
-static gimple *
+static bool
 gimple_expand_vec_set_expr (struct function *fun, gimple_stmt_iterator *gsi)
 {
   enum tree_code code;
   gcall *new_stmt = NULL;
   gassign *ass_stmt = NULL;
+  bool cfg_changed = false;
 
   /* Only consider code == GIMPLE_ASSIGN.  */
   gassign *stmt = dyn_cast<gassign *> (gsi_stmt (*gsi));
   if (!stmt)
-    return NULL;
+    return false;
 
   tree lhs = gimple_assign_lhs (stmt);
   code = TREE_CODE (lhs);
   if (code != ARRAY_REF)
-    return NULL;
+    return false;
 
   tree val = gimple_assign_rhs1 (stmt);
   tree op0 = TREE_OPERAND (lhs, 0);
@@ -98,12 +99,15 @@ gimple_expand_vec_set_expr (struct function *fun, gimple_stmt_iterator *gsi)
 	  gimple_set_location (ass_stmt, loc);
 	  gsi_insert_before (gsi, ass_stmt, GSI_SAME_STMT);
 
+	  basic_block bb = gimple_bb (stmt);
 	  gimple_move_vops (ass_stmt, stmt);
-	  gsi_remove (gsi, true);
+	  if (gsi_remove (gsi, true)
+	      && gimple_purge_dead_eh_edges (bb))
+	    cfg_changed = true;
 	}
     }
 
-  return ass_stmt;
+  return cfg_changed;
 }
 
 /* Expand all VEC_COND_EXPR gimple assignments into calls to internal
@@ -297,6 +301,7 @@ gimple_expand_vec_exprs (struct function *fun)
   basic_block bb;
   hash_map<tree, unsigned int> vec_cond_ssa_name_uses;
   auto_bitmap dce_ssa_names;
+  bool cfg_changed = false;
 
   FOR_EACH_BB_FN (bb, fun)
     {
@@ -311,7 +316,7 @@ gimple_expand_vec_exprs (struct function *fun)
 	      gsi_replace (&gsi, g, false);
 	    }
 
-	  gimple_expand_vec_set_expr (fun, &gsi);
+	  cfg_changed |= gimple_expand_vec_set_expr (fun, &gsi);
 	  if (gsi_end_p (gsi))
 	    break;
 	}
@@ -323,7 +328,7 @@ gimple_expand_vec_exprs (struct function *fun)
 
   simple_dce_from_worklist (dce_ssa_names);
 
-  return 0;
+  return cfg_changed ? TODO_cleanup_cfg : 0;
 }
 
 namespace {
diff --git a/gcc/testsuite/gcc.dg/torture/pr105484.c b/gcc/testsuite/gcc.dg/torture/pr105484.c
new file mode 100644
index 00000000000..f2a5eb8a7ee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr105484.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fnon-call-exceptions -fno-tree-dce -fno-tree-forwprop" } */
+/* { dg-additional-options "-march=cannonlake" { target x86_64-*-* i?86-*-* } } */
+
+typedef int __attribute__((__vector_size__ (16))) V;
+
+void bar (int i);
+
+void
+foo (int i)
+{
+  V v;
+  __builtin_mul_overflow (7, i, &v[i]);
+  bar ((V){}[3]);
+}


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

only message in thread, other threads:[~2022-05-05  8:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05  8:37 [gcc r13-129] tree-optimization/105484 - VEC_SET and EH 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).