[gcc r12-7132] middle-end/104464 - ISEL and non-call EH #2

Richard Biener rguenth@gcc.gnu.org
Wed Feb 9 14:50:12 GMT 2022


https://gcc.gnu.org/g:8f8f8c68b434eb32756284dd8e80cfbdff524a20

commit r12-7132-g8f8f8c68b434eb32756284dd8e80cfbdff524a20
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Feb 9 14:52:24 2022 +0100

    middle-end/104464 - ISEL and non-call EH #2
    
    The following adjusts the earlier change to still allow an
    uncritical replacement.
    
    2022-02-09  Richard Biener  <rguenther@suse.de>
    
            PR middle-end/104464
            * gimple-isel.cc (gimple_expand_vec_cond_expr): Postpone
            throwing check to after unproblematic replacement.
    
            * gcc.dg/pr104464.c: New testcase.

Diff:
---
 gcc/gimple-isel.cc              | 28 ++++++++++++++--------------
 gcc/testsuite/gcc.dg/pr104464.c | 11 +++++++++++
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc
index 1d93766b704..3635585bf45 100644
--- a/gcc/gimple-isel.cc
+++ b/gcc/gimple-isel.cc
@@ -178,11 +178,7 @@ gimple_expand_vec_cond_expr (struct function *fun, gimple_stmt_iterator *gsi,
 	}
 
       gassign *def_stmt = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (op0));
-      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))
+      if (def_stmt)
 	{
 	  tcode = gimple_assign_rhs_code (def_stmt);
 	  op0a = gimple_assign_rhs1 (def_stmt);
@@ -195,7 +191,6 @@ gimple_expand_vec_cond_expr (struct function *fun, gimple_stmt_iterator *gsi,
 						     tcode);
 
 	  /* Try to fold x CMP y ? -1 : 0 to x CMP y.  */
-
 	  if (can_compute_op0
 	      && integer_minus_onep (op1)
 	      && integer_zerop (op2)
@@ -207,14 +202,19 @@ gimple_expand_vec_cond_expr (struct function *fun, gimple_stmt_iterator *gsi,
 	      return new_stmt;
 	    }
 
-	  if (can_compute_op0
-	      && used_vec_cond_exprs >= 2
-	      && (get_vcond_mask_icode (mode, TYPE_MODE (op0_type))
-		  != CODE_FOR_nothing))
-	    {
-	      /* Keep the SSA name and use vcond_mask.  */
-	      tcode = TREE_CODE (op0);
-	    }
+	  /* 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.  */
+	  if (stmt_can_throw_internal (fun, def_stmt))
+	    tcode = TREE_CODE (op0);
+
+	  /* If we can compute op0 and have multiple uses, keep the SSA
+	     name and use vcond_mask.  */
+	  else if (can_compute_op0
+		   && used_vec_cond_exprs >= 2
+		   && (get_vcond_mask_icode (mode, TYPE_MODE (op0_type))
+		       != CODE_FOR_nothing))
+	    tcode = TREE_CODE (op0);
 	}
       else
 	tcode = TREE_CODE (op0);
diff --git a/gcc/testsuite/gcc.dg/pr104464.c b/gcc/testsuite/gcc.dg/pr104464.c
new file mode 100644
index 00000000000..ed6a22c39d5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr104464.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fnon-call-exceptions -fno-tree-dce -fno-tree-forwprop -fsignaling-nans" } */
+
+typedef double __attribute__((__vector_size__(16))) F;
+F f;
+
+void
+foo(void)
+{
+  f += (F)(f != (F){}[0]);
+}


More information about the Gcc-cvs mailing list