From patchwork Fri Jun 30 14:06:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 114731 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10393298vqr; Fri, 30 Jun 2023 07:07:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlHfLoYVZ1EQD6ZtdXv1IYGe5WxycV3khlVAZNumaXWvtrSJYNwS/SmQMk3iGSDhV5AjMfv5 X-Received: by 2002:a17:906:c453:b0:974:c32c:b485 with SMTP id ck19-20020a170906c45300b00974c32cb485mr1918895ejb.45.1688134065236; Fri, 30 Jun 2023 07:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688134065; cv=none; d=google.com; s=arc-20160816; b=aAduXHgAVlxmPwB4hlGopRSGPJ5/CjImP52FnKNunLxrxD9G51wO5gniZeqsrsU1LC EctENHsQuqbSsG4mp1kK4IFN6Md/WH0oU5HqRoqUGlhM3PXP4BTK6IuPSBDPFu3Cl9at oAqA9w95bEU12V4c3Gs5eIDvq1U5QqvnfKF9beqATdDOhdEQTQ1yrW80DASvjlb3CYG2 pDoBeOHpL1u1AjrDCBj5GlT5/ElTxJvqRhqIz/MWFs9khOZ4TCgm2FaOzpp9qWaPO0g8 tXXFe6A5hhoLw1OihLAzMhnJdU+LiteVNwqh7WAjnpgxg61LfcpjDPwZoKDD0f0FjMIg ArMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:to:subject :message-id:date:mime-version:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=csPLsDbzNAQvY6AruhuIOnwoAloXurn409L2VhOR27g=; fh=XNn3asQvIblazGK92GBt13dVv+YmGV3pBS0JC29ZQco=; b=vCEWeL+EicFxeJIzYSoNme/b5U0Ob2Oig5nH7s2lCkKQxzupZzFzqEE3n3MZ5gHcRm KSQDI+qh5gLHUTLxtjt3MgEk8/iwwbO8X1vORCQnh0qQLNQkMmli6EV3YYhNpWUnw3+f M+dnYfeCf971/ba4/iv/N1CJA4lnYi9riVZ0giy0H5Xi/IGoNnS9fo2LLbJUorHUW5JP ZQhR/WhHoIfEmXK52QzuQlZs/RqDP3/yiuEPi4rozNYL3RQiJNs+CQWUGES48TsZMlrs j+CqZShl3IznTuCHZMoVz3TzC1CaIXoKogAxrF+BHAWw0oTdWmeigDqnAwVlE4ilKGWY 0Vdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="J827h+/i"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d8-20020a1709061f4800b0098d0a88d4fasi8522992ejk.808.2023.06.30.07.07.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 07:07:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="J827h+/i"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C708C38313B6 for ; Fri, 30 Jun 2023 14:07:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C708C38313B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688134053; bh=csPLsDbzNAQvY6AruhuIOnwoAloXurn409L2VhOR27g=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=J827h+/iYXWDHSgDHaKHuA2xxPLlfl0DDT4w+QWf1eloJcCjDkCrf3FxFNg41EYCB qoy8PwEONfopJ+i8aFotiKD3L7/X81ICMkbeeNGfLZ+Wejac0CLtob3mCSG+3CXWTp uCNCssYTDBD9yr55nHIv67p6vKraCDyFv+rqI3ik= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 9BC10387088F for ; Fri, 30 Jun 2023 14:06:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9BC10387088F Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-51d9123a8abso2103943a12.2 for ; Fri, 30 Jun 2023 07:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688133997; x=1690725997; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=csPLsDbzNAQvY6AruhuIOnwoAloXurn409L2VhOR27g=; b=WJmld6y1YmPc7xEm2xJ6YuUOfy9aTjAvJHxWY9a8ymERdyRN5zVplPqp0ZmKGmJkC8 RD4UODg+LOkXT6qtbsVSgugOWVEzbGWPJAs1JDbb1EuZUFbj/hoBE+IMb5lVZPK8ZTDA LKJMONrk2d+zoQgx3nXKBSlC5q6biXp3FV6agWQPwApbx8LBtsDtaqZCbGKbtsUw2NH7 LVZ0B2NmuBXqH1YiUPKuW5aecONeb697rIkHFmrDc9IjIQ2VSUKgFNqrxmaxZ8XZohVf /38qfOHF3xC47ewdQGSr+5td7bUsIuXmSkBZdv5EXBXRIwb8kEJbAOtKM+X8DhDK1V+2 fkKA== X-Gm-Message-State: ABy/qLYwo47CU33+ung1uDAg3ToKre0YuOjzTjg6XxRJz0BMpEBz5AkQ PWQFdeQjBarWP30nBCsy0vTTWfvb0pPATOpsonvsyLfnO1ptUQ== X-Received: by 2002:aa7:c249:0:b0:51d:e561:a9ab with SMTP id y9-20020aa7c249000000b0051de561a9abmr1760489edo.16.1688133996831; Fri, 30 Jun 2023 07:06:36 -0700 (PDT) MIME-Version: 1.0 Date: Fri, 30 Jun 2023 16:06:25 +0200 Message-ID: Subject: [committed] fold-const+optabs: Change return type of predicate functions from int to bool To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Uros Bizjak via Gcc-patches From: Uros Bizjak Reply-To: Uros Bizjak Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770136866029142808?= X-GMAIL-MSGID: =?utf-8?q?1770136866029142808?= 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. 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; } /* 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) } /* 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; } /* 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); } -/* 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; } /* 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) /* 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);