public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] fold-const+optabs: Change return type of predicate functions from int to bool
@ 2023-06-30 14:06 Uros Bizjak
  0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2023-06-30 14:06 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]

Also change some internal variables and function argument from int to bool.

gcc/ChangeLog:

    * fold-const.h (multiple_of_p): Change return type from int to bool.
    * fold-const.cc (split_tree): Change negl_p, neg_litp_p,
    neg_conp_p and neg_var_p variables to bool.
    (const_binop): Change sat_p variable to bool.
    (merge_ranges): Change no_overlap variable to bool.
    (extract_muldiv_1): Change same_p variable to bool.
    (tree_swap_operands_p): Update function body for bool return type.
    (fold_truth_andor): Change commutative variable to bool.
    (multiple_of_p): Change return type
    from int to void and adjust function body accordingly.
    * optabs.h (expand_twoval_unop): Change return type from int to bool.
    (expand_twoval_binop): Ditto.
    (can_compare_p): Ditto.
    (have_add2_insn): Ditto.
    (have_addptr3_insn): Ditto.
    (have_sub2_insn): Ditto.
    (have_insn_for): Ditto.
    * optabs.cc (add_equal_note): Ditto.
    (widen_operand): Change no_extend argument from int to bool.
    (expand_binop): Ditto.
    (expand_twoval_unop): Change return type
    from int to void and adjust function body accordingly.
    (expand_twoval_binop): Ditto.
    (can_compare_p): Ditto.
    (have_add2_insn): Ditto.
    (have_addptr3_insn): Ditto.
    (have_sub2_insn): Ditto.
    (have_insn_for): Ditto.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 22022 bytes --]

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index ac90a594fcc..a02ede79fed 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -922,8 +922,8 @@ split_tree (tree in, tree type, enum tree_code code,
     {
       tree op0 = TREE_OPERAND (in, 0);
       tree op1 = TREE_OPERAND (in, 1);
-      int neg1_p = TREE_CODE (in) == MINUS_EXPR;
-      int neg_litp_p = 0, neg_conp_p = 0, neg_var_p = 0;
+      bool neg1_p = TREE_CODE (in) == MINUS_EXPR;
+      bool neg_litp_p = false, neg_conp_p = false, neg_var_p = false;
 
       /* First see if either of the operands is a literal, then a constant.  */
       if (TREE_CODE (op0) == INTEGER_CST || TREE_CODE (op0) == REAL_CST
@@ -1450,7 +1450,7 @@ const_binop (enum tree_code code, tree arg1, tree arg2)
       FIXED_VALUE_TYPE f2;
       FIXED_VALUE_TYPE result;
       tree t, type;
-      int sat_p;
+      bool sat_p;
       bool overflow_p;
 
       /* The following codes are handled by fixed_arithmetic.  */
@@ -5680,7 +5680,7 @@ bool
 merge_ranges (int *pin_p, tree *plow, tree *phigh, int in0_p, tree low0,
 	      tree high0, int in1_p, tree low1, tree high1)
 {
-  int no_overlap;
+  bool no_overlap;
   int subset;
   int temp;
   tree tem;
@@ -6855,7 +6855,7 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type,
 		    > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)))
 		? wide_type : type);
   tree t1, t2;
-  int same_p = tcode == code;
+  bool same_p = tcode == code;
   tree op0 = NULL_TREE, op1 = NULL_TREE;
   bool sub_strict_overflow_p;
 
@@ -7467,17 +7467,17 @@ bool
 tree_swap_operands_p (const_tree arg0, const_tree arg1)
 {
   if (CONSTANT_CLASS_P (arg1))
-    return 0;
+    return false;
   if (CONSTANT_CLASS_P (arg0))
-    return 1;
+    return true;
 
   STRIP_NOPS (arg0);
   STRIP_NOPS (arg1);
 
   if (TREE_CONSTANT (arg1))
-    return 0;
+    return false;
   if (TREE_CONSTANT (arg0))
-    return 1;
+    return true;
 
   /* It is preferable to swap two SSA_NAME to ensure a canonical form
      for commutative and comparison operators.  Ensuring a canonical
@@ -7486,21 +7486,21 @@ tree_swap_operands_p (const_tree arg0, const_tree arg1)
   if (TREE_CODE (arg0) == SSA_NAME
       && TREE_CODE (arg1) == SSA_NAME
       && SSA_NAME_VERSION (arg0) > SSA_NAME_VERSION (arg1))
-    return 1;
+    return true;
 
   /* Put SSA_NAMEs last.  */
   if (TREE_CODE (arg1) == SSA_NAME)
-    return 0;
+    return false;
   if (TREE_CODE (arg0) == SSA_NAME)
-    return 1;
+    return true;
 
   /* Put variables last.  */
   if (DECL_P (arg1))
-    return 0;
+    return false;
   if (DECL_P (arg0))
-    return 1;
+    return true;
 
-  return 0;
+  return false;
 }
 
 
@@ -9693,10 +9693,10 @@ fold_truth_andor (location_t loc, enum tree_code code, tree type,
       tree a01 = TREE_OPERAND (arg0, 1);
       tree a10 = TREE_OPERAND (arg1, 0);
       tree a11 = TREE_OPERAND (arg1, 1);
-      int commutative = ((TREE_CODE (arg0) == TRUTH_OR_EXPR
-			  || TREE_CODE (arg0) == TRUTH_AND_EXPR)
-			 && (code == TRUTH_AND_EXPR
-			     || code == TRUTH_OR_EXPR));
+      bool commutative = ((TREE_CODE (arg0) == TRUTH_OR_EXPR
+			   || TREE_CODE (arg0) == TRUTH_AND_EXPR)
+			  && (code == TRUTH_AND_EXPR
+			      || code == TRUTH_OR_EXPR));
 
       if (operand_equal_p (a00, a10, 0))
 	return fold_build2_loc (loc, TREE_CODE (arg0), type, a00,
@@ -14012,8 +14012,8 @@ fold_binary_initializer_loc (location_t loc, tree_code code, tree type,
 #undef START_FOLD_INIT
 #undef END_FOLD_INIT
 
-/* Determine if first argument is a multiple of second argument.  Return 0 if
-   it is not, or we cannot easily determined it to be.
+/* Determine if first argument is a multiple of second argument.  Return
+   false if it is not, or we cannot easily determined it to be.
 
    An example of the sort of thing we care about (at this point; this routine
    could surely be made more general, and expanded to do what the *_DIV_EXPR's
@@ -14058,17 +14058,17 @@ fold_binary_initializer_loc (location_t loc, tree_code code, tree type,
    NOWRAP is mostly used to treat expressions in TYPE_SIZE and friends
    as not wrapping even though they are generally using unsigned arithmetic.  */
 
-int
+bool
 multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
 {
   gimple *stmt;
   tree op1, op2;
 
   if (operand_equal_p (top, bottom, 0))
-    return 1;
+    return true;
 
   if (TREE_CODE (type) != INTEGER_TYPE)
-    return 0;
+    return false;
 
   switch (TREE_CODE (top))
     {
@@ -14076,7 +14076,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
       /* Bitwise and provides a power of two multiple.  If the mask is
 	 a multiple of BOTTOM then TOP is a multiple of BOTTOM.  */
       if (!integer_pow2p (bottom))
-	return 0;
+	return false;
       return (multiple_of_p (type, TREE_OPERAND (top, 1), bottom, nowrap)
 	      || multiple_of_p (type, TREE_OPERAND (top, 0), bottom, nowrap));
 
@@ -14087,7 +14087,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
       if (!nowrap
 	  && !TYPE_OVERFLOW_UNDEFINED (type)
 	  && !integer_pow2p (bottom))
-	return 0;
+	return false;
       if (TREE_CODE (bottom) == INTEGER_CST)
 	{
 	  op1 = TREE_OPERAND (top, 0);
@@ -14097,7 +14097,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
 	  if (TREE_CODE (op2) == INTEGER_CST)
 	    {
 	      if (multiple_of_p (type, op2, bottom, nowrap))
-		return 1;
+		return true;
 	      /* Handle multiple_of_p ((x * 2 + 2) * 4, 8).  */
 	      if (multiple_of_p (type, bottom, op2, nowrap))
 		{
@@ -14129,7 +14129,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
 				    nowrap);
 	    }
 	}
-      return 0;
+      return false;
 
     case MINUS_EXPR:
     case PLUS_EXPR:
@@ -14139,7 +14139,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
       if (!nowrap
 	  && !TYPE_OVERFLOW_UNDEFINED (type)
 	  && !integer_pow2p (bottom))
-	return 0;
+	return false;
 
       /* Handle cases like op0 + 0xfffffffd as op0 - 3 if the expression has
 	 unsigned type.  For example, (X / 3) + 0xfffffffd is multiple of 3,
@@ -14163,7 +14163,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
       if ((TREE_CODE (TREE_TYPE (TREE_OPERAND (top, 0))) != INTEGER_TYPE)
 	  || (TYPE_PRECISION (type)
 	      < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (top, 0)))))
-	return 0;
+	return false;
       /* NOWRAP only extends to operations in the outermost type so
 	 make sure to strip it off here.  */
       return multiple_of_p (TREE_TYPE (TREE_OPERAND (top, 0)),
@@ -14178,7 +14178,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
 
     case INTEGER_CST:
       if (TREE_CODE (bottom) != INTEGER_CST || integer_zerop (bottom))
-	return 0;
+	return false;
       return wi::multiple_of_p (wi::to_widest (top), wi::to_widest (bottom),
 				SIGNED);
 
@@ -14204,7 +14204,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
 	      && integer_pow2p (bottom)
 	      && wi::multiple_of_p (wi::to_widest (op2),
 				    wi::to_widest (bottom), UNSIGNED))
-	    return 1;
+	    return true;
 
 	  op1 = gimple_assign_rhs1 (stmt);
 	  if (code == MINUS_EXPR
@@ -14215,7 +14215,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
 	      && (code = gimple_assign_rhs_code (stmt)) == TRUNC_MOD_EXPR
 	      && operand_equal_p (op1, gimple_assign_rhs1 (stmt), 0)
 	      && operand_equal_p (bottom, gimple_assign_rhs2 (stmt), 0))
-	    return 1;
+	    return true;
 	}
 
       /* fall through */
@@ -14225,7 +14225,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
 	return multiple_p (wi::to_poly_widest (top),
 			   wi::to_poly_widest (bottom));
 
-      return 0;
+      return false;
     }
 }
 
diff --git a/gcc/fold-const.h b/gcc/fold-const.h
index 24c50fcc557..3d08528a20c 100644
--- a/gcc/fold-const.h
+++ b/gcc/fold-const.h
@@ -103,7 +103,7 @@ extern void fold_overflow_warning (const char*, enum warn_strict_overflow_code);
 extern enum tree_code fold_div_compare (enum tree_code, tree, tree,
 					tree *, tree *, bool *);
 extern bool operand_equal_p (const_tree, const_tree, unsigned int flags = 0);
-extern int multiple_of_p (tree, const_tree, const_tree, bool = true);
+extern bool multiple_of_p (tree, const_tree, const_tree, bool = true);
 #define omit_one_operand(T1,T2,T3)\
    omit_one_operand_loc (UNKNOWN_LOCATION, T1, T2, T3)
 extern tree omit_one_operand_loc (location_t, tree, tree, tree);
diff --git a/gcc/optabs.cc b/gcc/optabs.cc
index 89ab55b72ae..0a2bcf3620c 100644
--- a/gcc/optabs.cc
+++ b/gcc/optabs.cc
@@ -63,13 +63,13 @@ void debug_optab_libfuncs (void);
    the result of operation CODE applied to OP0 (and OP1 if it is a binary
    operation).  OP0_MODE is OP0's mode.
 
-   If the last insn does not set TARGET, don't do anything, but return 1.
+   If the last insn does not set TARGET, don't do anything, but return true.
 
    If the last insn or a previous insn sets TARGET and TARGET is one of OP0
-   or OP1, don't add the REG_EQUAL note but return 0.  Our caller can then
+   or OP1, don't add the REG_EQUAL note but return false.  Our caller can then
    try again, ensuring that TARGET is not one of the operands.  */
 
-static int
+static bool
 add_equal_note (rtx_insn *insns, rtx target, enum rtx_code code, rtx op0,
 		rtx op1, machine_mode op0_mode)
 {
@@ -84,10 +84,10 @@ add_equal_note (rtx_insn *insns, rtx target, enum rtx_code code, rtx op0,
       && GET_RTX_CLASS (code) != RTX_COMM_COMPARE
       && GET_RTX_CLASS (code) != RTX_COMPARE
       && GET_RTX_CLASS (code) != RTX_UNARY)
-    return 1;
+    return true;
 
   if (GET_CODE (target) == ZERO_EXTRACT)
-    return 1;
+    return true;
 
   for (last_insn = insns;
        NEXT_INSN (last_insn) != NULL_RTX;
@@ -118,20 +118,20 @@ add_equal_note (rtx_insn *insns, rtx target, enum rtx_code code, rtx op0,
 	      && (rtx_equal_p (SET_DEST (set), XEXP (SET_SRC (set), 0))
 		  || (op1 && rtx_equal_p (SET_DEST (set),
 					  XEXP (SET_SRC (set), 1)))))
-	    return 1;
+	    return true;
 	}
-      return 0;
+      return false;
     }
 
   set = set_for_reg_notes (last_insn);
   if (set == NULL_RTX)
-    return 1;
+    return true;
 
   if (! rtx_equal_p (SET_DEST (set), target)
       /* For a STRICT_LOW_PART, the REG_NOTE applies to what is inside it.  */
       && (GET_CODE (SET_DEST (set)) != STRICT_LOW_PART
 	  || ! rtx_equal_p (XEXP (SET_DEST (set), 0), target)))
-    return 1;
+    return true;
 
   if (GET_RTX_CLASS (code) == RTX_UNARY)
     switch (code)
@@ -165,7 +165,7 @@ add_equal_note (rtx_insn *insns, rtx target, enum rtx_code code, rtx op0,
 
   set_unique_reg_note (last_insn, REG_EQUAL, note);
 
-  return 1;
+  return true;
 }
 \f
 /* Given two input operands, OP0 and OP1, determine what the correct from_mode
@@ -193,14 +193,14 @@ widened_mode (machine_mode to_mode, rtx op0, rtx op1)
 }
 \f
 /* Widen OP to MODE and return the rtx for the widened operand.  UNSIGNEDP
-   says whether OP is signed or unsigned.  NO_EXTEND is nonzero if we need
+   says whether OP is signed or unsigned.  NO_EXTEND is true if we need
    not actually do a sign-extend or zero-extend, but can leave the
    higher-order bits of the result rtx undefined, for example, in the case
    of logical operations, but not right shifts.  */
 
 static rtx
 widen_operand (rtx op, machine_mode mode, machine_mode oldmode,
-	       int unsignedp, int no_extend)
+	       int unsignedp, bool no_extend)
 {
   rtx result;
   scalar_int_mode int_mode;
@@ -1657,7 +1657,7 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1,
 		    != CODE_FOR_nothing)))
 	  {
 	    rtx xop0 = op0, xop1 = op1;
-	    int no_extend = 0;
+	    bool no_extend = false;
 
 	    /* For certain integer operations, we need not actually extend
 	       the narrow operands, as long as we will truncate
@@ -1669,7 +1669,7 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1,
 		 || binoptab == smul_optab || binoptab == ashl_optab)
 		&& mclass == MODE_INT)
 	      {
-		no_extend = 1;
+		no_extend = true;
 		xop0 = avoid_expensive_constant (mode, binoptab, 0,
 						 xop0, unsignedp);
 		if (binoptab != ashl_optab)
@@ -2262,7 +2262,7 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1,
 		  && optab_libfunc (binoptab, wider_mode)))
 	    {
 	      rtx xop0 = op0, xop1 = op1;
-	      int no_extend = 0;
+	      bool no_extend = false;
 
 	      /* For certain integer operations, we need not actually extend
 		 the narrow operands, as long as we will truncate
@@ -2273,7 +2273,7 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1,
 		   || binoptab == add_optab || binoptab == sub_optab
 		   || binoptab == smul_optab || binoptab == ashl_optab)
 		  && mclass == MODE_INT)
-		no_extend = 1;
+		no_extend = true;
 
 	      xop0 = widen_operand (xop0, wider_mode, mode,
 				    unsignedp, no_extend);
@@ -2372,9 +2372,9 @@ sign_expand_binop (machine_mode mode, optab uoptab, optab soptab,
    the result is not actually wanted.  We will generate it into
    a dummy pseudo-reg and discard it.  They may not both be zero.
 
-   Returns 1 if this operation can be performed; 0 if not.  */
+   Returns true if this operation can be performed; false if not.  */
 
-int
+bool
 expand_twoval_unop (optab unoptab, rtx op0, rtx targ0, rtx targ1,
 		    int unsignedp)
 {
@@ -2403,7 +2403,7 @@ expand_twoval_unop (optab unoptab, rtx op0, rtx targ0, rtx targ1,
       create_fixed_operand (&ops[1], targ1);
       create_convert_operand_from (&ops[2], op0, mode, unsignedp);
       if (maybe_expand_insn (icode, 3, ops))
-	return 1;
+	return true;
     }
 
   /* It can't be done in this mode.  Can we do it in a wider mode?  */
@@ -2422,7 +2422,7 @@ expand_twoval_unop (optab unoptab, rtx op0, rtx targ0, rtx targ1,
 		{
 		  convert_move (targ0, t0, unsignedp);
 		  convert_move (targ1, t1, unsignedp);
-		  return 1;
+		  return true;
 		}
 	      else
 		delete_insns_since (last);
@@ -2431,7 +2431,7 @@ expand_twoval_unop (optab unoptab, rtx op0, rtx targ0, rtx targ1,
     }
 
   delete_insns_since (entry_last);
-  return 0;
+  return false;
 }
 \f
 /* Generate code to perform an operation specified by BINOPTAB
@@ -2444,9 +2444,9 @@ expand_twoval_unop (optab unoptab, rtx op0, rtx targ0, rtx targ1,
    the result is not actually wanted.  We will generate it into
    a dummy pseudo-reg and discard it.  They may not both be zero.
 
-   Returns 1 if this operation can be performed; 0 if not.  */
+   Returns true if this operation can be performed; false if not.  */
 
-int
+bool
 expand_twoval_binop (optab binoptab, rtx op0, rtx op1, rtx targ0, rtx targ1,
 		     int unsignedp)
 {
@@ -2483,7 +2483,7 @@ expand_twoval_binop (optab binoptab, rtx op0, rtx op1, rtx targ0, rtx targ1,
       create_convert_operand_from (&ops[2], xop1, mode, unsignedp);
       create_fixed_operand (&ops[3], targ1);
       if (maybe_expand_insn (icode, 4, ops))
-	return 1;
+	return true;
       delete_insns_since (last);
     }
 
@@ -2505,7 +2505,7 @@ expand_twoval_binop (optab binoptab, rtx op0, rtx op1, rtx targ0, rtx targ1,
 		{
 		  convert_move (targ0, t0, unsignedp);
 		  convert_move (targ1, t1, unsignedp);
-		  return 1;
+		  return true;
 		}
 	      else
 		delete_insns_since (last);
@@ -2514,7 +2514,7 @@ expand_twoval_binop (optab binoptab, rtx op0, rtx op1, rtx targ0, rtx targ1,
     }
 
   delete_insns_since (entry_last);
-  return 0;
+  return false;
 }
 
 /* Expand the two-valued library call indicated by BINOPTAB, but
@@ -4298,7 +4298,7 @@ emit_libcall_block (rtx_insn *insns, rtx target, rtx result, rtx equiv)
   emit_libcall_block_1 (insns, target, result, equiv, false);
 }
 \f
-/* Nonzero if we can perform a comparison of mode MODE straightforwardly.
+/* True if we can perform a comparison of mode MODE straightforwardly.
    PURPOSE describes how this comparison will be used.  CODE is the rtx
    comparison code we will be using.
 
@@ -4306,7 +4306,7 @@ emit_libcall_block (rtx_insn *insns, rtx target, rtx result, rtx equiv)
    required to implement all of the normal bcc operations, but not
    required to implement all (or any) of the unordered bcc operations.  */
 
-int
+bool
 can_compare_p (enum rtx_code code, machine_mode mode,
 	       enum can_compare_purpose purpose)
 {
@@ -4319,21 +4319,21 @@ can_compare_p (enum rtx_code code, machine_mode mode,
       if (purpose == ccp_jump
           && (icode = optab_handler (cbranch_optab, mode)) != CODE_FOR_nothing
           && insn_operand_matches (icode, 0, test))
-        return 1;
+	return true;
       if (purpose == ccp_store_flag
           && (icode = optab_handler (cstore_optab, mode)) != CODE_FOR_nothing
           && insn_operand_matches (icode, 1, test))
-        return 1;
+	return true;
       if (purpose == ccp_cmov
 	  && optab_handler (cmov_optab, mode) != CODE_FOR_nothing)
-	return 1;
+	return true;
 
       mode = GET_MODE_WIDER_MODE (mode).else_void ();
       PUT_MODE (test, mode);
     }
   while (mode != VOIDmode);
 
-  return 0;
+  return false;
 }
 
 /* Return whether RTL code CODE corresponds to an unsigned optab.  */
@@ -5369,7 +5369,7 @@ gen_add3_insn (rtx r0, rtx r1, rtx c)
   return GEN_FCN (icode) (r0, r1, c);
 }
 
-int
+bool
 have_add2_insn (rtx x, rtx y)
 {
   enum insn_code icode;
@@ -5379,14 +5379,14 @@ have_add2_insn (rtx x, rtx y)
   icode = optab_handler (add_optab, GET_MODE (x));
 
   if (icode == CODE_FOR_nothing)
-    return 0;
+    return false;
 
   if (!insn_operand_matches (icode, 0, x)
       || !insn_operand_matches (icode, 1, x)
       || !insn_operand_matches (icode, 2, y))
-    return 0;
+    return false;
 
-  return 1;
+  return true;
 }
 
 /* Generate and return an insn body to add Y to X.  */
@@ -5406,7 +5406,7 @@ gen_addptr3_insn (rtx x, rtx y, rtx z)
 /* Return true if the target implements an addptr pattern and X, Y,
    and Z are valid for the pattern predicates.  */
 
-int
+bool
 have_addptr3_insn (rtx x, rtx y, rtx z)
 {
   enum insn_code icode;
@@ -5416,14 +5416,14 @@ have_addptr3_insn (rtx x, rtx y, rtx z)
   icode = optab_handler (addptr3_optab, GET_MODE (x));
 
   if (icode == CODE_FOR_nothing)
-    return 0;
+    return false;
 
   if (!insn_operand_matches (icode, 0, x)
       || !insn_operand_matches (icode, 1, y)
       || !insn_operand_matches (icode, 2, z))
-    return 0;
+    return false;
 
-  return 1;
+  return true;
 }
 
 /* Generate and return an insn body to subtract Y from X.  */
@@ -5457,7 +5457,7 @@ gen_sub3_insn (rtx r0, rtx r1, rtx c)
   return GEN_FCN (icode) (r0, r1, c);
 }
 
-int
+bool
 have_sub2_insn (rtx x, rtx y)
 {
   enum insn_code icode;
@@ -5467,14 +5467,14 @@ have_sub2_insn (rtx x, rtx y)
   icode = optab_handler (sub_optab, GET_MODE (x));
 
   if (icode == CODE_FOR_nothing)
-    return 0;
+    return false;
 
   if (!insn_operand_matches (icode, 0, x)
       || !insn_operand_matches (icode, 1, x)
       || !insn_operand_matches (icode, 2, y))
-    return 0;
+    return false;
 
-  return 1;
+  return true;
 }
 \f
 /* Generate the body of an insn to extend Y (with mode MFROM)
@@ -6057,7 +6057,7 @@ expand_sfix_optab (rtx to, rtx from, convert_optab tab)
 \f
 /* Report whether we have an instruction to perform the operation
    specified by CODE on operands of mode MODE.  */
-int
+bool
 have_insn_for (enum rtx_code code, machine_mode mode)
 {
   return (code_to_optab (code)
diff --git a/gcc/optabs.h b/gcc/optabs.h
index 29ccbe9235e..781d5548be9 100644
--- a/gcc/optabs.h
+++ b/gcc/optabs.h
@@ -200,10 +200,10 @@ extern rtx sign_expand_binop (machine_mode, optab, optab, rtx, rtx,
 			      rtx, int, enum optab_methods);
 
 /* Generate code to perform an operation on one operand with two results.  */
-extern int expand_twoval_unop (optab, rtx, rtx, rtx, int);
+extern bool expand_twoval_unop (optab, rtx, rtx, rtx, int);
 
 /* Generate code to perform an operation on two operands with two results.  */
-extern int expand_twoval_binop (optab, rtx, rtx, rtx, rtx, int);
+extern bool expand_twoval_binop (optab, rtx, rtx, rtx, rtx, int);
 
 /* Generate code to perform an operation on two operands with two
    results, using a library function.  */
@@ -243,8 +243,8 @@ enum can_compare_purpose
 
 /* Nonzero if a compare of mode MODE can be done straightforwardly
    (without splitting it into pieces).  */
-extern int can_compare_p (enum rtx_code, machine_mode,
-			  enum can_compare_purpose);
+extern bool can_compare_p (enum rtx_code, machine_mode,
+			   enum can_compare_purpose);
 
 /* Return whether the backend can emit a vector comparison (vec_cmp/vec_cmpu)
    for code CODE, comparing operands of mode VALUE_MODE and producing a result
@@ -298,12 +298,12 @@ rtx emit_conditional_add (rtx, enum rtx_code, rtx, rtx, machine_mode,
    Likewise for subtraction and for just copying.  */
 extern rtx_insn *gen_add2_insn (rtx, rtx);
 extern rtx_insn *gen_add3_insn (rtx, rtx, rtx);
-extern int have_add2_insn (rtx, rtx);
+extern bool have_add2_insn (rtx, rtx);
 extern rtx_insn *gen_addptr3_insn (rtx, rtx, rtx);
-extern int have_addptr3_insn (rtx, rtx, rtx);
+extern bool have_addptr3_insn (rtx, rtx, rtx);
 extern rtx_insn *gen_sub2_insn (rtx, rtx);
 extern rtx_insn *gen_sub3_insn (rtx, rtx, rtx);
-extern int have_sub2_insn (rtx, rtx);
+extern bool have_sub2_insn (rtx, rtx);
 
 /* Generate the body of an insn to extend Y (with mode MFROM)
    into X (with mode MTO).  Do zero-extension if UNSIGNEDP is nonzero.  */
@@ -323,7 +323,7 @@ extern bool expand_sfix_optab (rtx, rtx, convert_optab);
 
 /* Report whether the machine description contains an insn which can
    perform the operation described by CODE and MODE.  */
-extern int have_insn_for (enum rtx_code, machine_mode);
+extern bool have_insn_for (enum rtx_code, machine_mode);
 
 /* Generate a conditional trap instruction.  */
 extern rtx_insn *gen_cond_trap (enum rtx_code, rtx, rtx, rtx);

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

only message in thread, other threads:[~2023-06-30 14:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 14:06 [committed] fold-const+optabs: Change return type of predicate functions from int to bool Uros Bizjak

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).