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.
{
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
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. */
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;
> 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;
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
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;
}
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,
#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
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))
{
/* 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));
if (!nowrap
&& !TYPE_OVERFLOW_UNDEFINED (type)
&& !integer_pow2p (bottom))
- return 0;
+ return false;
if (TREE_CODE (bottom) == INTEGER_CST)
{
op1 = TREE_OPERAND (top, 0);
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))
{
nowrap);
}
}
- return 0;
+ return false;
case MINUS_EXPR:
case PLUS_EXPR:
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,
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)),
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);
&& 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
&& (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 */
return multiple_p (wi::to_poly_widest (top),
wi::to_poly_widest (bottom));
- return 0;
+ return false;
}
}
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);
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)
{
&& 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;
&& (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)
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
}
\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;
!= 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
|| 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)
&& 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
|| 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);
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)
{
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? */
{
convert_move (targ0, t0, unsignedp);
convert_move (targ1, t1, unsignedp);
- return 1;
+ return true;
}
else
delete_insns_since (last);
}
delete_insns_since (entry_last);
- return 0;
+ return false;
}
\f
/* Generate code to perform an operation specified by BINOPTAB
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)
{
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);
}
{
convert_move (targ0, t0, unsignedp);
convert_move (targ1, t1, unsignedp);
- return 1;
+ return true;
}
else
delete_insns_since (last);
}
delete_insns_since (entry_last);
- return 0;
+ return false;
}
/* Expand the two-valued library call indicated by BINOPTAB, but
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.
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)
{
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. */
return GEN_FCN (icode) (r0, r1, c);
}
-int
+bool
have_add2_insn (rtx x, rtx y)
{
enum insn_code icode;
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. */
/* 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;
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. */
return GEN_FCN (icode) (r0, r1, c);
}
-int
+bool
have_sub2_insn (rtx x, rtx y)
{
enum insn_code icode;
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)
\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)
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. */
/* 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
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. */
/* 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);