public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10630] middle-end/104450 - ISEL and non-call EH
@ 2023-04-17 10:44 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-04-17 10:44 UTC (permalink / raw)
  To: gcc-cvs

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

commit r11-10630-g9dcc5d68cd935c9ff0ef023fe8b3bd7ab67d0687
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Feb 9 09:11:28 2022 +0100

    middle-end/104450 - ISEL and non-call EH
    
    The following avoids merging a vector compare with EH with a
    VEC_COND_EXPR.  We should be able to do fallback expansion and if
    we really are for the optimization we need quite some shuffling
    to arrange for the proper EH redirection in all cases, IMHO not
    worth it.
    
    2022-02-09  Richard Biener  <rguenther@suse.de>
    
            PR middle-end/104450
            * gimple-isel.cc: Pass cfun around.
            (+gimple_expand_vec_cond_expr): Do not combine a throwing
            comparison with the select.
    
            * g++.dg/torture/pr104450.C: New testcase.
    
    (cherry picked from commit 871afdc512be0510cbd4fa0928e5a1bd0681766e)

Diff:
---
 gcc/gimple-isel.cc                      | 24 ++++++++++++++----------
 gcc/testsuite/g++.dg/torture/pr104450.C | 16 ++++++++++++++++
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc
index 3690782eca4..69f6063949b 100644
--- a/gcc/gimple-isel.cc
+++ b/gcc/gimple-isel.cc
@@ -50,7 +50,7 @@ along with GCC; see the file COPYING3.  If not see
      u = _8;  */
 
 static gimple *
-gimple_expand_vec_set_expr (gimple_stmt_iterator *gsi)
+gimple_expand_vec_set_expr (struct function *fun, gimple_stmt_iterator *gsi)
 {
   enum tree_code code;
   gcall *new_stmt = NULL;
@@ -76,7 +76,7 @@ gimple_expand_vec_set_expr (gimple_stmt_iterator *gsi)
       tree pos = TREE_OPERAND (lhs, 1);
       tree view_op0 = TREE_OPERAND (op0, 0);
       machine_mode outermode = TYPE_MODE (TREE_TYPE (view_op0));
-      if (auto_var_in_fn_p (view_op0, cfun->decl)
+      if (auto_var_in_fn_p (view_op0, fun->decl)
 	  && !TREE_ADDRESSABLE (view_op0) && can_vec_set_var_idx_p (outermode))
 	{
 	  location_t loc = gimple_location (stmt);
@@ -111,7 +111,7 @@ gimple_expand_vec_set_expr (gimple_stmt_iterator *gsi)
    function based on type of selected expansion.  */
 
 static gimple *
-gimple_expand_vec_cond_expr (gimple_stmt_iterator *gsi,
+gimple_expand_vec_cond_expr (struct function *fun, gimple_stmt_iterator *gsi,
 			     hash_map<tree, unsigned int> *vec_cond_ssa_name_uses)
 {
   tree lhs, op0a = NULL_TREE, op0b = NULL_TREE;
@@ -179,7 +179,11 @@ gimple_expand_vec_cond_expr (gimple_stmt_iterator *gsi,
 	}
 
       gassign *def_stmt = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (op0));
-      if (def_stmt)
+      if (def_stmt
+	  /* When the compare has EH we do not want to forward it when
+	     it has multiple uses and in general because of the complication
+	     with EH redirection.  */
+	  && !stmt_can_throw_internal (fun, def_stmt))
 	{
 	  tcode = gimple_assign_rhs_code (def_stmt);
 	  op0a = gimple_assign_rhs1 (def_stmt);
@@ -291,18 +295,18 @@ gimple_expand_vec_cond_expr (gimple_stmt_iterator *gsi,
    VEC_COND_EXPR assignments.  */
 
 static unsigned int
-gimple_expand_vec_exprs (void)
+gimple_expand_vec_exprs (struct function *fun)
 {
   gimple_stmt_iterator gsi;
   basic_block bb;
   hash_map<tree, unsigned int> vec_cond_ssa_name_uses;
   auto_bitmap dce_ssa_names;
 
-  FOR_EACH_BB_FN (bb, cfun)
+  FOR_EACH_BB_FN (bb, fun)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple *g = gimple_expand_vec_cond_expr (&gsi,
+	  gimple *g = gimple_expand_vec_cond_expr (fun, &gsi,
 						   &vec_cond_ssa_name_uses);
 	  if (g != NULL)
 	    {
@@ -311,7 +315,7 @@ gimple_expand_vec_exprs (void)
 	      gsi_replace (&gsi, g, false);
 	    }
 
-	  gimple_expand_vec_set_expr (&gsi);
+	  gimple_expand_vec_set_expr (fun, &gsi);
 	  if (gsi_end_p (gsi))
 	    break;
 	}
@@ -354,9 +358,9 @@ public:
       return true;
     }
 
-  virtual unsigned int execute (function *)
+  virtual unsigned int execute (function *fun)
     {
-      return gimple_expand_vec_exprs ();
+      return gimple_expand_vec_exprs (fun);
     }
 
 }; // class pass_gimple_isel
diff --git a/gcc/testsuite/g++.dg/torture/pr104450.C b/gcc/testsuite/g++.dg/torture/pr104450.C
new file mode 100644
index 00000000000..402a4849e54
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr104450.C
@@ -0,0 +1,16 @@
+// { dg-do compile }
+// { dg-additional-options "-fnon-call-exceptions" }
+// { dg-additional-options "-mavx512f" { target x86_64-*-* i?86-*-* } }
+
+#define vectsize 64
+typedef int __attribute__((__vector_size__ (vectsize))) V;
+typedef float __attribute__((__vector_size__ (vectsize))) F;
+F f;
+V v;
+struct g{~g();};
+void
+foo (void)
+{
+  g t;
+  v += (V) (0 <= f);
+}

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

only message in thread, other threads:[~2023-04-17 10:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-17 10:44 [gcc r11-10630] middle-end/104450 - ISEL and non-call 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).