This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR78515


I am testing the following to beat some sanity into 
compute_complex_assign_jump_func.  There's still that odd 'stmt2'
hanging around that gets set to sth else than stmt with

  op1 = gimple_assign_rhs1 (stmt);

  if (TREE_CODE (op1) == SSA_NAME)
    {
      if (SSA_NAME_IS_DEFAULT_DEF (op1))
        index = ipa_get_param_decl_index (info, SSA_NAME_VAR (op1));
      else
        {
          index = load_from_param (fbi, info->descriptors,
                                   SSA_NAME_DEF_STMT (op1));
          stmt2 = SSA_NAME_DEF_STMT (op1);

I assume that the original code wanted to restrict its processing
to unary RHS of 'stmt' but still this "skips" arbitrary unary
operations in 'stmt'?  But maybe I'm not understanding jump functions
here.  If we have

  _2 = -param_1(D);
  _3 = ~_2;

and stmt is _3 then we create a unary pass through JF with - (and the ~
gets lost?).

Anyway, the following is a step in the right direction -- if you
want to address the above (maybe with some comments) you can
happily take the patch from here, otherwise we can followup this
patch.

Bootstrap & regtest running on x86_64-unknown-linux-gnu, ok for trunk?

Thanks,
Richard.

2016-11-25  Richard Biener  <rguenther@suse.de>

	PR ipa/78515
	* ipa-prop.c (compute_complex_assign_jump_func): Properly identify
	unary, binary and single RHSs.
	* tree.def (BIT_INSERT_EXPR): Adjust tree code name.

	* gcc.dg/torture/pr78515.c: New testcase.

diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 90c19fc..642111d 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -1177,29 +1177,37 @@ compute_complex_assign_jump_func (struct ipa_func_body_info *fbi,
 
   if (index >= 0)
     {
-      tree op2 = gimple_assign_rhs2 (stmt);
-
-      if (op2)
+      switch (gimple_assign_rhs_class (stmt))
 	{
-	  if (!is_gimple_ip_invariant (op2)
-	      || (TREE_CODE_CLASS (gimple_expr_code (stmt)) != tcc_comparison
-		  && !useless_type_conversion_p (TREE_TYPE (name),
-						 TREE_TYPE (op1))))
-	    return;
-
-	  ipa_set_jf_arith_pass_through (jfunc, index, op2,
-					 gimple_assign_rhs_code (stmt));
-	}
-      else if (gimple_assign_single_p (stmt))
-	{
-	  bool agg_p = parm_ref_data_pass_through_p (fbi, index, call, tc_ssa);
-	  ipa_set_jf_simple_pass_through (jfunc, index, agg_p);
+	case GIMPLE_BINARY_RHS:
+	  {
+	    tree op2 = gimple_assign_rhs2 (stmt);
+	    if (!is_gimple_ip_invariant (op2)
+		|| ((TREE_CODE_CLASS (gimple_assign_rhs_code (stmt))
+		     != tcc_comparison)
+		    && !useless_type_conversion_p (TREE_TYPE (name),
+						   TREE_TYPE (op1))))
+	      return;
+
+	    ipa_set_jf_arith_pass_through (jfunc, index, op2,
+					   gimple_assign_rhs_code (stmt));
+	    break;
+	  }
+	case GIMPLE_SINGLE_RHS:
+	  {
+	    bool agg_p = parm_ref_data_pass_through_p (fbi, index, call,
+						       tc_ssa);
+	    ipa_set_jf_simple_pass_through (jfunc, index, agg_p);
+	    break;
+	  }
+	case GIMPLE_UNARY_RHS:
+	  if (is_gimple_assign (stmt2)
+	      && gimple_assign_rhs_class (stmt2) == GIMPLE_UNARY_RHS
+	      && ! CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt2)))
+	    ipa_set_jf_unary_pass_through (jfunc, index,
+					   gimple_assign_rhs_code (stmt2));
+	default:;
 	}
-      else if (is_gimple_assign (stmt2)
-	       && (gimple_expr_code (stmt2) != NOP_EXPR)
-	       && (TREE_CODE_CLASS (gimple_expr_code (stmt2)) == tcc_unary))
-	ipa_set_jf_unary_pass_through (jfunc, index,
-				       gimple_assign_rhs_code (stmt2));
       return;
     }
 
diff --git a/gcc/testsuite/gcc.dg/torture/pr78515.c b/gcc/testsuite/gcc.dg/torture/pr78515.c
new file mode 100644
index 0000000..d700db5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr78515.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mavx512bw" { target x86_64-*-* i?86-*-* } } */
+
+typedef unsigned V __attribute__ ((vector_size (64)));
+
+V g;
+
+static V
+baz (V u, V v)
+{
+  g += u;
+  return v + g + 1;
+}
+
+static V
+bar (V u)
+{
+  u[0] = 0;
+  return baz(u, (V){});
+}
+
+V
+foo ()
+{
+  return (V){bar((V){})[0]};
+}
diff --git a/gcc/tree.def b/gcc/tree.def
index 2c35540..e093307 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -865,7 +865,7 @@ DEFTREECODE (FDESC_EXPR, "fdesc_expr", tcc_expression, 2)
    introducing a quaternary operation.
    The replaced bits shall be fully inside the container.  If the container
    is of vector type, then these bits shall be aligned with its elements.  */
-DEFTREECODE (BIT_INSERT_EXPR, "bit_field_insert", tcc_expression, 3)
+DEFTREECODE (BIT_INSERT_EXPR, "bit_insert_expr", tcc_expression, 3)
 
 /* Given two real or integer operands of the same type,
    returns a complex value of the corresponding complex type.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]