Patchwork [1/4] Introduce and use unknown_optab

login
register
mail settings
Submitter Richard Henderson
Date July 19, 2012, 6:24 p.m.
Message ID <1342722250-25934-2-git-send-email-rth@redhat.com>
Download mbox | patch
Permalink /patch/172009/
State New
Headers show

Comments

Richard Henderson - July 19, 2012, 6:24 p.m.
Prep for a later patch where this becomes an enum value.
---
 gcc/builtins.c           |    2 +-
 gcc/dojump.c             |   13 +++++--------
 gcc/optabs.c             |    6 +++---
 gcc/optabs.h             |    2 ++
 gcc/tree-vect-generic.c  |   30 +++++++++++++++---------------
 gcc/tree-vect-patterns.c |    2 +-
 gcc/tree-vect-stmts.c    |    2 +-
 7 files changed, 28 insertions(+), 29 deletions(-)

Patch

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 4fb3d53..23c7437 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -2352,7 +2352,7 @@  static enum insn_code
 interclass_mathfn_icode (tree arg, tree fndecl)
 {
   bool errno_set = false;
-  optab builtin_optab = 0;
+  optab builtin_optab = unknown_optab;
   enum machine_mode mode;
 
   switch (DECL_FUNCTION_CODE (fndecl))
diff --git a/gcc/dojump.c b/gcc/dojump.c
index 06b8d04..24eed63 100644
--- a/gcc/dojump.c
+++ b/gcc/dojump.c
@@ -1028,19 +1028,16 @@  do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp,
 	  op0 = op1;
 	  op1 = tmp;
 	}
-
       else if (SCALAR_FLOAT_MODE_P (mode)
 	       && ! can_compare_p (code, mode, ccp_jump)
-
-	       /* Never split ORDERED and UNORDERED.  These must be implemented.  */
+	       /* Never split ORDERED and UNORDERED.
+		  These must be implemented.  */
 	       && (code != ORDERED && code != UNORDERED)
-
-               /* Split a floating-point comparison if we can jump on other
-	          conditions...  */
+               /* Split a floating-point comparison if
+		  we can jump on other conditions...  */
 	       && (have_insn_for (COMPARE, mode)
-
 	           /* ... or if there is no libcall for it.  */
-	           || code_to_optab[code] == NULL))
+	           || code_to_optab[code] == unknown_optab))
         {
 	  enum rtx_code first_code;
 	  bool and_them = split_comparison (code, mode, &first_code, &code);
diff --git a/gcc/optabs.c b/gcc/optabs.c
index e1ecc65..f30a20d 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -390,7 +390,7 @@  optab_for_tree_code (enum tree_code code, const_tree type,
       if (TREE_CODE (type) == VECTOR_TYPE)
 	{
 	  if (subtype == optab_vector)
-	    return TYPE_SATURATING (type) ? NULL : vashl_optab;
+	    return TYPE_SATURATING (type) ? unknown_optab : vashl_optab;
 
 	  gcc_assert (subtype == optab_scalar);
 	}
@@ -560,7 +560,7 @@  optab_for_tree_code (enum tree_code code, const_tree type,
       return trapv ? absv_optab : abs_optab;
 
     default:
-      return NULL;
+      return unknown_optab;
     }
 }
 
@@ -1580,7 +1580,7 @@  expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
      shift by a vector.  If so, broadcast the scalar into a vector.  */
   if (mclass == MODE_VECTOR_INT)
     {
-      optab otheroptab = NULL;
+      optab otheroptab = unknown_optab;
 
       if (binoptab == ashl_optab)
 	otheroptab = vashl_optab;
diff --git a/gcc/optabs.h b/gcc/optabs.h
index 816fc29..c502766 100644
--- a/gcc/optabs.h
+++ b/gcc/optabs.h
@@ -412,6 +412,8 @@  enum optab_index
   OTI_MAX
 };
 
+#define unknown_optab NULL
+
 #define ssadd_optab (&optab_table[OTI_ssadd])
 #define usadd_optab (&optab_table[OTI_usadd])
 #define sssub_optab (&optab_table[OTI_sssub])
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index b0f41d1..9c8a70e 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -414,14 +414,14 @@  add_rshift (gimple_stmt_iterator *gsi, tree type, tree op0, int *shiftcnts)
   if (scalar_shift)
     {
       op = optab_for_tree_code (RSHIFT_EXPR, type, optab_scalar);
-      if (op != NULL
+      if (op != unknown_optab
 	  && optab_handler (op, TYPE_MODE (type)) != CODE_FOR_nothing)
 	return gimplify_build2 (gsi, RSHIFT_EXPR, type, op0,
 				build_int_cst (NULL_TREE, shiftcnts[0]));
     }
 
   op = optab_for_tree_code (RSHIFT_EXPR, type, optab_vector);
-  if (op != NULL
+  if (op != unknown_optab
       && optab_handler (op, TYPE_MODE (type)) != CODE_FOR_nothing)
     {
       tree *vec = XALLOCAVEC (tree, nunits);
@@ -462,7 +462,7 @@  expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
     return NULL_TREE;
 
   op = optab_for_tree_code (RSHIFT_EXPR, type, optab_vector);
-  if (op == NULL
+  if (op == unknown_optab
       || optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing)
     has_vector_shift = false;
 
@@ -689,7 +689,7 @@  expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
 	      /* t1 = op0 + addend;
 		 q = t1 >> shift;  */
 	      op = optab_for_tree_code (PLUS_EXPR, type, optab_default);
-	      if (op != NULL
+	      if (op != unknown_optab
 		  && optab_handler (op, TYPE_MODE (type)) != CODE_FOR_nothing)
 		{
 		  cur_op = gimplify_build2 (gsi, PLUS_EXPR, type, op0, addend);
@@ -708,7 +708,7 @@  expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
 				     << shifts[i]) - 1);
 	  mask = build_vector (type, vec);
 	  op = optab_for_tree_code (BIT_AND_EXPR, type, optab_default);
-	  if (op != NULL
+	  if (op != unknown_optab
 	      && optab_handler (op, TYPE_MODE (type)) != CODE_FOR_nothing)
 	    {
 	      if (unsignedp)
@@ -720,7 +720,7 @@  expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
 		     t2 = t1 & mask;
 		     r = t2 - addend;  */
 		  op = optab_for_tree_code (PLUS_EXPR, type, optab_default);
-		  if (op != NULL
+		  if (op != unknown_optab
 		      && optab_handler (op, TYPE_MODE (type))
 			 != CODE_FOR_nothing)
 		    {
@@ -730,7 +730,7 @@  expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
 						cur_op, mask);
 		      op = optab_for_tree_code (MINUS_EXPR, type,
 						optab_default);
-		      if (op != NULL
+		      if (op != unknown_optab
 			  && optab_handler (op, TYPE_MODE (type))
 			     != CODE_FOR_nothing)
 			return gimplify_build2 (gsi, MINUS_EXPR, type,
@@ -801,13 +801,13 @@  expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
 	 t4 = t1 + t3;
 	 q = t4 >> (post_shift - 1);  */
       op = optab_for_tree_code (MINUS_EXPR, type, optab_default);
-      if (op == NULL
+      if (op == unknown_optab
 	  || optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing)
 	return NULL_TREE;
       tem = gimplify_build2 (gsi, MINUS_EXPR, type, op0, cur_op);
       tem = add_rshift (gsi, type, tem, shift_temps);
       op = optab_for_tree_code (PLUS_EXPR, type, optab_default);
-      if (op == NULL
+      if (op == unknown_optab
 	  || optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing)
 	return NULL_TREE;
       tem = gimplify_build2 (gsi, PLUS_EXPR, type, cur_op, tem);
@@ -829,7 +829,7 @@  expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
       if ((mode & 2) == 0)
 	{
 	  op = optab_for_tree_code (PLUS_EXPR, type, optab_default);
-	  if (op == NULL
+	  if (op == unknown_optab
 	      || optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing)
 	    return NULL_TREE;
 	  cur_op = gimplify_build2 (gsi, PLUS_EXPR, type, cur_op, op0);
@@ -841,7 +841,7 @@  expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
       if (tem == NULL_TREE)
 	return NULL_TREE;
       op = optab_for_tree_code (MINUS_EXPR, type, optab_default);
-      if (op == NULL
+      if (op == unknown_optab
 	  || optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing)
 	return NULL_TREE;
       if ((mode & 1) == 0)
@@ -860,12 +860,12 @@  expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
      t1 = q * oprnd1;
      r = oprnd0 - t1;  */
   op = optab_for_tree_code (MULT_EXPR, type, optab_default);
-  if (op == NULL
+  if (op == unknown_optab
       || optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing)
     return NULL_TREE;
   tem = gimplify_build2 (gsi, MULT_EXPR, type, cur_op, op1);
   op = optab_for_tree_code (MINUS_EXPR, type, optab_default);
-  if (op == NULL
+  if (op == unknown_optab
       || optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing)
     return NULL_TREE;
   return gimplify_build2 (gsi, MINUS_EXPR, type, op0, tem);
@@ -1235,7 +1235,7 @@  expand_vector_operations_1 (gimple_stmt_iterator *gsi)
   tree lhs, rhs1, rhs2 = NULL, type, compute_type;
   enum tree_code code;
   enum machine_mode compute_mode;
-  optab op = NULL;
+  optab op = unknown_optab;
   enum gimple_rhs_class rhs_class;
   tree new_rhs;
 
@@ -1344,7 +1344,7 @@  expand_vector_operations_1 (gimple_stmt_iterator *gsi)
   /* Optabs will try converting a negation into a subtraction, so
      look for it as well.  TODO: negation of floating-point vectors
      might be turned into an exclusive OR toggling the sign bit.  */
-  if (op == NULL
+  if (op == unknown_optab
       && code == NEGATE_EXPR
       && INTEGRAL_TYPE_P (TREE_TYPE (type)))
     op = optab_for_tree_code (MINUS_EXPR, type, optab_default);
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 05202a8..420a4f4 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -1675,7 +1675,7 @@  vect_recog_divmod_pattern (VEC (gimple, heap) **stmts,
   /* If the target can handle vectorized division or modulo natively,
      don't attempt to optimize this.  */
   optab = optab_for_tree_code (rhs_code, vectype, optab_default);
-  if (optab != NULL)
+  if (optab != unknown_optab)
     {
       enum machine_mode vec_mode = TYPE_MODE (vectype);
       int icode = (int) optab_handler (optab, vec_mode);
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index fb05063..9d137e8 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -6545,7 +6545,7 @@  supportable_narrowing_operation (enum tree_code code,
 	= lang_hooks.types.type_for_mode (TYPE_MODE (vectype_out), 0);
       interm_optab
 	= optab_for_tree_code (c1, intermediate_type, optab_default);
-      if (interm_optab != NULL
+      if (interm_optab != unknown_optab
 	  && (icode2 = optab_handler (optab1, vec_mode)) != CODE_FOR_nothing
 	  && insn_data[icode1].operand[0].mode
 	     == insn_data[icode2].operand[0].mode)