From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74960 invoked by alias); 6 Aug 2019 15:43:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 74904 invoked by uid 89); 6 Aug 2019 15:43:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_SOFTFAIL autolearn=ham version=3.3.1 spammy= X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Aug 2019 15:43:37 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hv1cY-0007Jp-4F for gcc-patches@gcc.gnu.org; Tue, 06 Aug 2019 11:43:36 -0400 Received: from mx2.suse.de ([195.135.220.15]:45198 helo=mx1.suse.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hv1cX-0007In-PG for gcc-patches@gcc.gnu.org; Tue, 06 Aug 2019 11:43:30 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 84139B0DA for ; Tue, 6 Aug 2019 15:43:26 +0000 (UTC) Resent-From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Resent-To: GCC Patches Resent-Date: Tue, 6 Aug 2019 17:43:26 +0200 Resent-Message-ID: <555b9cc5-e6e1-8efb-1a27-96ebfd2acfc1@suse.cz> Message-Id: <28d8daf7008fdb1172c0613c38be2c9ec4959c9a.1565105736.git.mliska@suse.cz> In-Reply-To: References: From: Martin Liska Date: Tue, 06 Aug 2019 15:43:00 -0000 Subject: [PATCH 1/9] Replace int with boolean in predicate functions. To: gcc-patches@gcc.gnu.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.22.0" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00379.txt.bz2 This is a multi-part message in MIME format. --------------2.22.0 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: quoted-printable Content-length: 433 gcc/ChangeLog: 2019-07-24 Martin Liska * fold-const.c (twoval_comparison_p): Replace int with bool as a return type. (simple_operand_p): Likewise. (operand_equal_p): Replace int with bool as a return type. * fold-const.h (operand_equal_p): Likewise. --- gcc/fold-const.c | 148 +++++++++++++++++++++++------------------------ gcc/fold-const.h | 2 +- 2 files changed, 75 insertions(+), 75 deletions(-) --------------2.22.0 Content-Type: text/x-patch; name="0001-Replace-int-with-boolean-in-predicate-functions.patch" Content-Disposition: attachment; filename="0001-Replace-int-with-boolean-in-predicate-functions.patch" Content-Transfer-Encoding: quoted-printable Content-length: 18279 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 716d7397b49..0bd68b5e2d4 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -115,11 +115,11 @@ static tree negate_expr (tree); static tree associate_trees (location_t, tree, tree, enum tree_code, tree); static enum comparison_code comparison_to_compcode (enum tree_code); static enum tree_code compcode_to_comparison (enum comparison_code); -static int twoval_comparison_p (tree, tree *, tree *); +static bool twoval_comparison_p (tree, tree *, tree *); static tree eval_subst (location_t, tree, tree, tree, tree, tree); static tree optimize_bit_field_compare (location_t, enum tree_code, tree, tree, tree); -static int simple_operand_p (const_tree); +static bool simple_operand_p (const_tree); static bool simple_operand_p_2 (tree); static tree range_binop (enum tree_code, tree, tree, int, tree, int); static tree range_predecessor (tree); @@ -2939,7 +2939,7 @@ combine_comparisons (location_t loc, addresses with TREE_CONSTANT flag set so we know that &var =3D=3D &var even if var is volatile. */ =20 -int +bool operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) { /* When checking, verify at the outermost operand_equal_p call that @@ -2958,10 +2958,10 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) hashval_t h1 =3D hstate1.end (); gcc_assert (h0 =3D=3D h1); } - return 1; + return true; } else - return 0; + return false; } =20 STRIP_ANY_LOCATION_WRAPPER (arg0); @@ -2971,19 +2971,19 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) if (TREE_CODE (arg0) =3D=3D ERROR_MARK || TREE_CODE (arg1) =3D=3D ERROR_= MARK || TREE_TYPE (arg0) =3D=3D error_mark_node || TREE_TYPE (arg1) =3D=3D error_mark_node) - return 0; + return false; =20 /* Similar, if either does not have a type (like a template id), they aren't equal. */ if (!TREE_TYPE (arg0) || !TREE_TYPE (arg1)) - return 0; + return false; =20 /* We cannot consider pointers to different address space equal. */ if (POINTER_TYPE_P (TREE_TYPE (arg0)) && POINTER_TYPE_P (TREE_TYPE (arg1)) && (TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (arg0))) !=3D TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (arg1))))) - return 0; + return false; =20 /* Check equality of integer constants before bailing out due to precision differences. */ @@ -3005,13 +3005,13 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) if (TYPE_UNSIGNED (TREE_TYPE (arg0)) !=3D TYPE_UNSIGNED (TREE_TYPE (= arg1)) || POINTER_TYPE_P (TREE_TYPE (arg0)) !=3D POINTER_TYPE_P (TREE_TYPE (arg1))) - return 0; + return false; =20 /* If both types don't have the same precision, then it is not safe to strip NOPs. */ if (element_precision (TREE_TYPE (arg0)) !=3D element_precision (TREE_TYPE (arg1))) - return 0; + return false; =20 STRIP_NOPS (arg0); STRIP_NOPS (arg1); @@ -3058,17 +3058,17 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) && TREE_CODE (TREE_OPERAND (arg0, 0)) =3D=3D ADDR_EXPR && TREE_OPERAND (TREE_OPERAND (arg0, 0), 0) =3D=3D arg1 && integer_zerop (TREE_OPERAND (arg0, 1))) - return 1; + return true; else if (TREE_CODE (arg1) =3D=3D MEM_REF && DECL_P (arg0) && TREE_CODE (TREE_OPERAND (arg1, 0)) =3D=3D ADDR_EXPR && TREE_OPERAND (TREE_OPERAND (arg1, 0), 0) =3D=3D arg0 && integer_zerop (TREE_OPERAND (arg1, 1))) - return 1; - return 0; + return true; + return false; } else - return 0; + return false; } =20 /* When not checking adddresses, this is needed for conversions and for @@ -3077,7 +3077,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) || TREE_CODE (TREE_TYPE (arg1)) =3D=3D ERROR_MARK || (TYPE_MODE (TREE_TYPE (arg0)) !=3D TYPE_MODE (TREE_TYPE (arg1)) && !(flags & OEP_ADDRESS_OF))) - return 0; + return false; =20 /* If ARG0 and ARG1 are the same SAVE_EXPR, they are necessarily equal. We don't care about side effects in that case because the SAVE_EXPR @@ -3092,7 +3092,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) && (TREE_CODE (arg0) =3D=3D SAVE_EXPR || (flags & OEP_MATCH_SIDE_EFFECTS) || (! TREE_SIDE_EFFECTS (arg0) && ! TREE_SIDE_EFFECTS (arg1)))) - return 1; + return true; =20 /* Next handle constant cases, those for which we can return 1 even if ONLY_CONST is set. */ @@ -3108,7 +3108,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) =20 case REAL_CST: if (real_identical (&TREE_REAL_CST (arg0), &TREE_REAL_CST (arg1))) - return 1; + return true; =20 =20 if (!HONOR_SIGNED_ZEROS (arg0)) @@ -3116,26 +3116,26 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) /* If we do not distinguish between signed and unsigned zero, consider them equal. */ if (real_zerop (arg0) && real_zerop (arg1)) - return 1; + return true; } - return 0; + return false; =20 case VECTOR_CST: { if (VECTOR_CST_LOG2_NPATTERNS (arg0) !=3D VECTOR_CST_LOG2_NPATTERNS (arg1)) - return 0; + return false; =20 if (VECTOR_CST_NELTS_PER_PATTERN (arg0) !=3D VECTOR_CST_NELTS_PER_PATTERN (arg1)) - return 0; + return false; =20 unsigned int count =3D vector_cst_encoded_nelts (arg0); for (unsigned int i =3D 0; i < count; ++i) if (!operand_equal_p (VECTOR_CST_ENCODED_ELT (arg0, i), VECTOR_CST_ENCODED_ELT (arg1, i), flags)) - return 0; - return 1; + return false; + return true; } =20 case COMPLEX_CST: @@ -3164,7 +3164,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) } =20 if (flags & OEP_ONLY_CONST) - return 0; + return false; =20 /* Define macros to test an operand from arg0 and arg1 for equality and a variant that allows null and views null as being different from any @@ -3187,7 +3187,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) case FIX_TRUNC_EXPR: if (TYPE_UNSIGNED (TREE_TYPE (arg0)) !=3D TYPE_UNSIGNED (TREE_TYPE (arg1))) - return 0; + return false; break; default: break; @@ -3199,7 +3199,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) case tcc_comparison: case tcc_binary: if (OP_SAME (0) && OP_SAME (1)) - return 1; + return true; =20 /* For commutative ops, allow the other order. */ return (commutative_tree_code (TREE_CODE (arg0)) @@ -3215,7 +3215,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) if ((flags & OEP_MATCH_SIDE_EFFECTS) =3D=3D 0 && (TREE_SIDE_EFFECTS (arg0) || TREE_SIDE_EFFECTS (arg1))) - return 0; + return false; =20 switch (TREE_CODE (arg0)) { @@ -3224,11 +3224,11 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) { if (TYPE_ALIGN (TREE_TYPE (arg0)) !=3D TYPE_ALIGN (TREE_TYPE (arg1))) - return 0; + return false; /* Verify that the access types are compatible. */ if (TYPE_MAIN_VARIANT (TREE_TYPE (arg0)) !=3D TYPE_MAIN_VARIANT (TREE_TYPE (arg1))) - return 0; + return false; } flags &=3D ~OEP_ADDRESS_OF; return OP_SAME (0); @@ -3238,7 +3238,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) if (!operand_equal_p (TYPE_SIZE (TREE_TYPE (arg0)), TYPE_SIZE (TREE_TYPE (arg1)), flags & ~OEP_ADDRESS_OF)) - return 0; + return false; =20 /* Fallthru. */ case REALPART_EXPR: @@ -3256,10 +3256,10 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) || !operand_equal_p (TYPE_SIZE (TREE_TYPE (arg0)), TYPE_SIZE (TREE_TYPE (arg1)), flags))) - return 0; + return false; /* Verify that access happens in similar types. */ if (!types_compatible_p (TREE_TYPE (arg0), TREE_TYPE (arg1))) - return 0; + return false; /* Verify that accesses are TBAA compatible. */ if (!alias_ptr_types_compatible_p (TREE_TYPE (TREE_OPERAND (arg0, 1)), @@ -3268,11 +3268,11 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) !=3D MR_DEPENDENCE_CLIQUE (arg1)) || (MR_DEPENDENCE_BASE (arg0) !=3D MR_DEPENDENCE_BASE (arg1))) - return 0; + return false; /* Verify that alignment is compatible. */ if (TYPE_ALIGN (TREE_TYPE (arg0)) !=3D TYPE_ALIGN (TREE_TYPE (arg1))) - return 0; + return false; } flags &=3D ~OEP_ADDRESS_OF; return (OP_SAME (0) && OP_SAME (1) @@ -3285,7 +3285,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) case ARRAY_REF: case ARRAY_RANGE_REF: if (!OP_SAME (0)) - return 0; + return false; flags &=3D ~OEP_ADDRESS_OF; /* Compare the array index by value if it is constant first as we may have different types but same value here. */ @@ -3313,18 +3313,18 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) may be NULL when we're called to compare MEM_EXPRs. */ if (!OP_SAME_WITH_NULL (0) || !OP_SAME (1)) - return 0; + return false; flags &=3D ~OEP_ADDRESS_OF; return OP_SAME_WITH_NULL (2); =20 case BIT_FIELD_REF: if (!OP_SAME (0)) - return 0; + return false; flags &=3D ~OEP_ADDRESS_OF; return OP_SAME (1) && OP_SAME (2); =20 default: - return 0; + return false; } =20 case tcc_expression: @@ -3347,7 +3347,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) case WIDEN_MULT_PLUS_EXPR: case WIDEN_MULT_MINUS_EXPR: if (!OP_SAME (2)) - return 0; + return false; /* The multiplcation operands are commutative. */ /* FALLTHRU */ =20 @@ -3355,7 +3355,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) case TRUTH_OR_EXPR: case TRUTH_XOR_EXPR: if (OP_SAME (0) && OP_SAME (1)) - return 1; + return true; =20 /* Otherwise take into account this is a commutative operation. */ return (operand_equal_p (TREE_OPERAND (arg0, 0), @@ -3365,7 +3365,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) =20 case COND_EXPR: if (! OP_SAME (1) || ! OP_SAME_WITH_NULL (2)) - return 0; + return false; flags &=3D ~OEP_ADDRESS_OF; return OP_SAME (0); =20 @@ -3392,17 +3392,17 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) case POSTINCREMENT_EXPR: if (flags & OEP_LEXICOGRAPHIC) return OP_SAME (0) && OP_SAME (1); - return 0; + return false; =20 case CLEANUP_POINT_EXPR: case EXPR_STMT: case SAVE_EXPR: if (flags & OEP_LEXICOGRAPHIC) return OP_SAME (0); - return 0; + return false; =20 default: - return 0; + return false; } =20 case tcc_vl_exp: @@ -3413,13 +3413,13 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) !=3D (CALL_EXPR_FN (arg1) =3D=3D NULL_TREE)) /* If not both CALL_EXPRs are either internal or normal function functions, then they are not equal. */ - return 0; + return false; else if (CALL_EXPR_FN (arg0) =3D=3D NULL_TREE) { /* If the CALL_EXPRs call different internal functions, then they are not equal. */ if (CALL_EXPR_IFN (arg0) !=3D CALL_EXPR_IFN (arg1)) - return 0; + return false; } else { @@ -3427,7 +3427,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) equal. */ if (! operand_equal_p (CALL_EXPR_FN (arg0), CALL_EXPR_FN (arg1), flags)) - return 0; + return false; } =20 /* FIXME: We could skip this test for OEP_MATCH_SIDE_EFFECTS. */ @@ -3438,7 +3438,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) else cef &=3D ECF_CONST; if (!cef && !(flags & OEP_LEXICOGRAPHIC)) - return 0; + return false; } =20 /* Now see if all the arguments are the same. */ @@ -3451,14 +3451,14 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) a0 =3D next_const_call_expr_arg (&iter0), a1 =3D next_const_call_expr_arg (&iter1)) if (! operand_equal_p (a0, a1, flags)) - return 0; + return false; =20 /* If we get here and both argument lists are exhausted then the CALL_EXPRs are equal. */ return ! (a0 || a1); } default: - return 0; + return false; } =20 case tcc_declaration: @@ -3480,7 +3480,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) constants). */ if (!VECTOR_TYPE_P (TREE_TYPE (arg0)) || !VECTOR_TYPE_P (TREE_TYPE (arg1))) - return 0; + return false; =20 /* Be sure that vectors constructed have the same representation. We only tested element precision and modes to match. @@ -3488,14 +3488,14 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) parts match. */ if (maybe_ne (TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0)), TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg1)))) - return 0; + return false; =20 vec *v0 =3D CONSTRUCTOR_ELTS (arg0); vec *v1 =3D CONSTRUCTOR_ELTS (arg1); unsigned int len =3D vec_safe_length (v0); =20 if (len !=3D vec_safe_length (v1)) - return 0; + return false; =20 for (unsigned int i =3D 0; i < len; i++) { @@ -3512,9 +3512,9 @@ operand_equal_p (const_tree arg0, const_tree arg1, un= signed int flags) || (c1->index && (TREE_CODE (c1->index) !=3D INTEGER_CST=20 || compare_tree_int (c1->index, i)))) - return 0; + return false; } - return 1; + return true; } else if (TREE_CODE (arg0) =3D=3D STATEMENT_LIST && (flags & OEP_LEXICOGRAPHIC)) @@ -3528,16 +3528,16 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) { /* The lists don't have the same number of statements. */ if (tsi_end_p (tsi1) ^ tsi_end_p (tsi2)) - return 0; + return false; if (tsi_end_p (tsi1) && tsi_end_p (tsi2)) - return 1; + return true; if (!operand_equal_p (tsi_stmt (tsi1), tsi_stmt (tsi2), flags & (OEP_LEXICOGRAPHIC | OEP_NO_HASH_CHECK))) - return 0; + return false; } } - return 0; + return false; =20 case tcc_statement: switch (TREE_CODE (arg0)) @@ -3545,17 +3545,17 @@ operand_equal_p (const_tree arg0, const_tree arg1, = unsigned int flags) case RETURN_EXPR: if (flags & OEP_LEXICOGRAPHIC) return OP_SAME_WITH_NULL (0); - return 0; + return false; case DEBUG_BEGIN_STMT: if (flags & OEP_LEXICOGRAPHIC) - return 1; - return 0; + return true; + return false; default: - return 0; + return false; } =20 default: - return 0; + return false; } =20 #undef OP_SAME @@ -3606,7 +3606,7 @@ operand_equal_for_comparison_p (tree arg0, tree arg1) =20 If this is true, return 1. Otherwise, return zero. */ =20 -static int +static bool twoval_comparison_p (tree arg, tree *cval1, tree *cval2) { enum tree_code code =3D TREE_CODE (arg); @@ -3630,14 +3630,14 @@ twoval_comparison_p (tree arg, tree *cval1, tree *c= val2) && twoval_comparison_p (TREE_OPERAND (arg, 1), cval1, cval2)); =20 case tcc_constant: - return 1; + return true; =20 case tcc_expression: if (code =3D=3D COND_EXPR) return (twoval_comparison_p (TREE_OPERAND (arg, 0), cval1, cval2) && twoval_comparison_p (TREE_OPERAND (arg, 1), cval1, cval2) && twoval_comparison_p (TREE_OPERAND (arg, 2), cval1, cval2)); - return 0; + return false; =20 case tcc_comparison: /* First see if we can handle the first operand, then the second. F= or @@ -3648,7 +3648,7 @@ twoval_comparison_p (tree arg, tree *cval1, tree *cva= l2) =20 if (operand_equal_p (TREE_OPERAND (arg, 0), TREE_OPERAND (arg, 1), 0)) - return 0; + return false; =20 if (*cval1 =3D=3D 0) *cval1 =3D TREE_OPERAND (arg, 0); @@ -3659,7 +3659,7 @@ twoval_comparison_p (tree arg, tree *cval1, tree *cva= l2) else if (operand_equal_p (*cval2, TREE_OPERAND (arg, 0), 0)) ; else - return 0; + return false; =20 if (operand_equal_p (*cval1, TREE_OPERAND (arg, 1), 0)) ; @@ -3668,12 +3668,12 @@ twoval_comparison_p (tree arg, tree *cval1, tree *c= val2) else if (operand_equal_p (*cval2, TREE_OPERAND (arg, 1), 0)) ; else - return 0; + return false; =20 - return 1; + return true; =20 default: - return 0; + return false; } } =0C @@ -4353,7 +4353,7 @@ decode_field_reference (location_t loc, tree *exp_, H= OST_WIDE_INT *pbitsize, /* Return nonzero if MASK represents a mask of SIZE ones in the low-order bit positions and MASK is SIGNED. */ =20 -static int +static bool all_ones_mask_p (const_tree mask, unsigned int size) { tree type =3D TREE_TYPE (mask); @@ -4408,7 +4408,7 @@ sign_bit_p (tree exp, const_tree val) /* Subroutine for fold_truth_andor_1: determine if an operand is simple en= ough to be evaluated unconditionally. */ =20 -static int +static bool simple_operand_p (const_tree exp) { /* Strip any conversions that don't change the machine mode. */ diff --git a/gcc/fold-const.h b/gcc/fold-const.h index eab2b47a260..54c850a3ee1 100644 --- a/gcc/fold-const.h +++ b/gcc/fold-const.h @@ -84,7 +84,7 @@ extern bool fold_deferring_overflow_warnings_p (void); 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 int operand_equal_p (const_tree, const_tree, unsigned int); +extern bool operand_equal_p (const_tree, const_tree, unsigned int); extern int multiple_of_p (tree, const_tree, const_tree); #define omit_one_operand(T1,T2,T3)\ omit_one_operand_loc (UNKNOWN_LOCATION, T1, T2, T3) --------------2.22.0--