From patchwork Thu Jul 13 08:46:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107607 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1930614qge; Thu, 13 Jul 2017 01:47:48 -0700 (PDT) X-Received: by 10.98.19.136 with SMTP id 8mr59849981pft.105.1499935668053; Thu, 13 Jul 2017 01:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935668; cv=none; d=google.com; s=arc-20160816; b=guqeaTxb5lY6xNKi8lBvcgCSZlDjeyXgrdPik+G6MoieUPGsoiLudtO5wJ1uzRr2XN +84EccabIcyPwoK5CX/m6yiJkhK4ou8rVGy2gXiI9eFUsQTQD+I3V5cPV55ZskYO+ezX Ai8rVYybPqPRTl9N6mEKIR64Ruo6LxIF1JpfpGgvlKuN+h8Q+iqiFhEUL/CITMNnJR14 ctmUvVZVEQXeQlKwgo+eWUh3LSpK1YsBsnEOInGom36FNPeLiYyyls1K6e+xSj5JF4Ec nXO3XfIYD5OJjMgpyopKfyjt2auS8e05D6OeOZElsyZelP12kLVq7U/Oc//FChjeTo+5 LMGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=selNIucqYhI+i9jDoReTI7xt96X3c46jUXXxoyGRhIs=; b=oz0ULxji4zV4miqSB2sq0BCVu10/Y6LrrlELhUwVxJdaYCLkK3xq+SiaEXT2Sa594+ M0vvBo2USV5yqfVwNJPq+WyHyxCoJeWMad+9CNsc7N023p3cp/PZ0ndYlCVyR45HwPN8 A+SbNwFf2AWKQPmH5u6tDsAsWRW+/F8n1byWxFR3v7E4pg8CDFgyTNkzO36y6akk3kj9 XCc8fW6MVwAhddVKFZSd3L9CbCln3uUPNnFmHSMtCqtxi2DQ/pu4i5Oi4ATwY4ePOKfw TMq5cZNJCO9/Co5uBRAyHL781uXtnabkp9uZNs8pkA1ndKdVFdK0zqSQG8WjRTvJPDfx zVKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=QQHSdACz; spf=pass (google.com: domain of gcc-patches-return-458012-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458012-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id x66si3692794pfb.38.2017.07.13.01.47.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458012-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=QQHSdACz; spf=pass (google.com: domain of gcc-patches-return-458012-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458012-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=rvnkVTNAVt6AvvdtGd68GmvYmyxdA ydxA5SMh6+nlXzA3zLIBQNCoG1j8rYOlhe2wotGeadL6l7jD4UozlhcGDhv42m+a k9c+mbeAY8Rfm7CH3OuxCnaHMtDF+cCTpqkHYfY583GYrna7vw2vxG++9D4Abj1N 9Xs45GpUr8MTJg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=3an6EODbvLEBL/s444+uEqTBHh0=; b=QQH SdACzojNs+ODvFDJ/ZOfAZQ5MkaOI3d2vJNCJ6rXNEifIXSeNcBlyeRJxR2rJXPY 0y+JbUasunMN0PF/e37yxSCQ+uW48WyM7drlB4BtgmuGAfX6sYmKLxZjmHCUXHL7 PSGRAdeWR3/AvykV05n6c+pGzIiQszrsI87fp0Ao= Received: (qmail 49392 invoked by alias); 13 Jul 2017 08:46:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 49061 invoked by uid 89); 13 Jul 2017 08:46:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Quick X-HELO: mail-wm0-f52.google.com Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:46:26 +0000 Received: by mail-wm0-f52.google.com with SMTP id 62so16541897wmw.1 for ; Thu, 13 Jul 2017 01:46:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=selNIucqYhI+i9jDoReTI7xt96X3c46jUXXxoyGRhIs=; b=HDa6G9p0/oGUGkNCZww20Q+tsLguU3f49o119es+X9k/I/hfizqgKoI0TTDHeKPifB Qr+r3mYFVPl0//2a25gMr/3ZSXGz9BsaMIiC498+fMt7njL7kDGbVa91d0lGf4DIyAwp x6WpV3G4mBbMNwXVGKCslwUBk2GAFg7aar8kgU4uokbh54Vz8KzI6LONeDwL+Prb1SFm 6Gec8APoQBBDvcOUqn1Xwjiowk+TszIDg0s2tLf+KgThnulPilDMUaFw+6w4L2gVeaR7 wj6nXA1L3DAnnovAWEPcuKl4CYAQdjJyU6k9xF0oxa74Q2ONht3IlfNprCCCEMzWov9o sVhA== X-Gm-Message-State: AIVw110EQydiSjSUpnN3bDrY35qXnsQ6oR6Fo1pzo4EcPpBSb5j23D7y HF7+XcKZ6amWg/2iJec4yQ== X-Received: by 10.28.1.8 with SMTP id 8mr1188321wmb.88.1499935581979; Thu, 13 Jul 2017 01:46:21 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 185sm5609633wmn.33.2017.07.13.01.46.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:46:21 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [21/77] Replace SCALAR_INT_MODE_P checks with is_a References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:46:19 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87mv88k9lw.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch replaces checks of "SCALAR_INT_MODE_P (...)" with "is_a (..., &var)" in cases where it becomes useful to refer to the mode as a scalar_int_mode. It also replaces some checks for the two constituent classes (MODE_INT and MODE_PARTIAL_INT). The patch also introduces is_a checks for some uses of HWI_COMPUTABLE_MODE_P, which is a subcondition of SCALAR_INT_MODE_P. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * wide-int.h (int_traits) New class. (int_traits) Likewise. * cfgexpand.c (expand_debug_expr): Use is_a . Use GET_MODE_UNIT_PRECISION and remove redundant test for SCALAR_INT_MODE_P. * combine.c (set_nonzero_bits_and_sign_copies): Use is_a . (find_split_point): Likewise. (combine_simplify_rtx): Likewise. (simplify_logical): Likewise. (expand_compound_operation): Likewise. (expand_field_assignment): Likewise. (make_compound_operation): Likewise. (extended_count): Likewise. (change_zero_ext): Likewise. (simplify_comparison): Likewise. * dwarf2out.c (scompare_loc_descriptor): Likewise. (ucompare_loc_descriptor): Likewise. (minmax_loc_descriptor): Likewise. (mem_loc_descriptor): Likewise. (loc_descriptor): Likewise. * expmed.c (init_expmed_one_mode): Likewise. * lra-constraints.c (lra_constraint_offset): Likewise. * optabs.c (prepare_libcall_arg): Likewise. * postreload.c (move2add_note_store): Likewise. * reload.c (operands_match_p): Likewise. * rtl.h (load_extend_op): Likewise. * rtlhooks.c (gen_lowpart_general): Likewise. * simplify-rtx.c (simplify_truncation): Likewise. (simplify_unary_operation_1): Likewise. (simplify_binary_operation_1): Likewise. (simplify_const_binary_operation): Likewise. (simplify_const_relational_operation): Likewise. (simplify_subreg): Likewise. * stor-layout.c (bitwise_mode_for_mode): Likewise. * var-tracking.c (adjust_mems): Likewise. (prepare_call_arguments): Likewise. gcc/ada/ * gcc-interface/decl.c (check_ok_for_atomic_type): Use is_a . * gcc-interface/trans.c (Pragma_to_gnu): Likewise. * gcc-interface/utils.c (gnat_type_for_mode): Likewise. gcc/fortran/ * trans-types.c (gfc_type_for_mode): Use is_a . Index: gcc/wide-int.h =================================================================== --- gcc/wide-int.h 2017-03-28 16:19:28.000000000 +0100 +++ gcc/wide-int.h 2017-07-13 09:18:32.530352523 +0100 @@ -1468,6 +1468,14 @@ wi::primitive_int_traits :: namespace wi { template <> + struct int_traits + : public primitive_int_traits {}; + + template <> + struct int_traits + : public primitive_int_traits {}; + + template <> struct int_traits : public primitive_int_traits {}; Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2017-07-13 09:18:30.888502896 +0100 +++ gcc/cfgexpand.c 2017-07-13 09:18:32.520353432 +0100 @@ -4137,6 +4137,7 @@ expand_debug_expr (tree exp) machine_mode inner_mode = VOIDmode; int unsignedp = TYPE_UNSIGNED (TREE_TYPE (exp)); addr_space_t as; + scalar_int_mode op1_mode; switch (TREE_CODE_CLASS (TREE_CODE (exp))) { @@ -4186,16 +4187,10 @@ expand_debug_expr (tree exp) case WIDEN_LSHIFT_EXPR: /* Ensure second operand isn't wider than the first one. */ inner_mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1))); - if (SCALAR_INT_MODE_P (inner_mode)) - { - machine_mode opmode = mode; - if (VECTOR_MODE_P (mode)) - opmode = GET_MODE_INNER (mode); - if (SCALAR_INT_MODE_P (opmode) - && (GET_MODE_PRECISION (opmode) - < GET_MODE_PRECISION (inner_mode))) - op1 = lowpart_subreg (opmode, op1, inner_mode); - } + if (is_a (inner_mode, &op1_mode) + && (GET_MODE_UNIT_PRECISION (mode) + < GET_MODE_PRECISION (op1_mode))) + op1 = lowpart_subreg (GET_MODE_INNER (mode), op1, op1_mode); break; default: break; Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:31.690429148 +0100 +++ gcc/combine.c 2017-07-13 09:18:32.521353341 +0100 @@ -1706,6 +1706,7 @@ update_rsp_from_reg_equal (reg_stat_type set_nonzero_bits_and_sign_copies (rtx x, const_rtx set, void *data) { rtx_insn *insn = (rtx_insn *) data; + scalar_int_mode mode; if (REG_P (x) && REGNO (x) >= FIRST_PSEUDO_REGISTER @@ -1713,13 +1714,14 @@ set_nonzero_bits_and_sign_copies (rtx x, say what its contents were. */ && ! REGNO_REG_SET_P (DF_LR_IN (ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb), REGNO (x)) - && HWI_COMPUTABLE_MODE_P (GET_MODE (x))) + && is_a (GET_MODE (x), &mode) + && HWI_COMPUTABLE_MODE_P (mode)) { reg_stat_type *rsp = ®_stat[REGNO (x)]; if (set == 0 || GET_CODE (set) == CLOBBER) { - rsp->nonzero_bits = GET_MODE_MASK (GET_MODE (x)); + rsp->nonzero_bits = GET_MODE_MASK (mode); rsp->sign_bit_copies = 1; return; } @@ -1749,7 +1751,7 @@ set_nonzero_bits_and_sign_copies (rtx x, break; if (!link) { - rsp->nonzero_bits = GET_MODE_MASK (GET_MODE (x)); + rsp->nonzero_bits = GET_MODE_MASK (mode); rsp->sign_bit_copies = 1; return; } @@ -1768,7 +1770,7 @@ set_nonzero_bits_and_sign_copies (rtx x, update_rsp_from_reg_equal (rsp, insn, set, x); else { - rsp->nonzero_bits = GET_MODE_MASK (GET_MODE (x)); + rsp->nonzero_bits = GET_MODE_MASK (mode); rsp->sign_bit_copies = 1; } } @@ -4926,37 +4928,38 @@ find_split_point (rtx *loc, rtx_insn *in /* See if this is a bitfield assignment with everything constant. If so, this is an IOR of an AND, so split it into that. */ if (GET_CODE (SET_DEST (x)) == ZERO_EXTRACT - && HWI_COMPUTABLE_MODE_P (GET_MODE (XEXP (SET_DEST (x), 0))) + && is_a (GET_MODE (XEXP (SET_DEST (x), 0)), + &inner_mode) + && HWI_COMPUTABLE_MODE_P (inner_mode) && CONST_INT_P (XEXP (SET_DEST (x), 1)) && CONST_INT_P (XEXP (SET_DEST (x), 2)) && CONST_INT_P (SET_SRC (x)) && ((INTVAL (XEXP (SET_DEST (x), 1)) + INTVAL (XEXP (SET_DEST (x), 2))) - <= GET_MODE_PRECISION (GET_MODE (XEXP (SET_DEST (x), 0)))) + <= GET_MODE_PRECISION (inner_mode)) && ! side_effects_p (XEXP (SET_DEST (x), 0))) { HOST_WIDE_INT pos = INTVAL (XEXP (SET_DEST (x), 2)); unsigned HOST_WIDE_INT len = INTVAL (XEXP (SET_DEST (x), 1)); unsigned HOST_WIDE_INT src = INTVAL (SET_SRC (x)); rtx dest = XEXP (SET_DEST (x), 0); - machine_mode mode = GET_MODE (dest); unsigned HOST_WIDE_INT mask = (HOST_WIDE_INT_1U << len) - 1; rtx or_mask; if (BITS_BIG_ENDIAN) - pos = GET_MODE_PRECISION (mode) - len - pos; + pos = GET_MODE_PRECISION (inner_mode) - len - pos; - or_mask = gen_int_mode (src << pos, mode); + or_mask = gen_int_mode (src << pos, inner_mode); if (src == mask) SUBST (SET_SRC (x), - simplify_gen_binary (IOR, mode, dest, or_mask)); + simplify_gen_binary (IOR, inner_mode, dest, or_mask)); else { - rtx negmask = gen_int_mode (~(mask << pos), mode); + rtx negmask = gen_int_mode (~(mask << pos), inner_mode); SUBST (SET_SRC (x), - simplify_gen_binary (IOR, mode, - simplify_gen_binary (AND, mode, + simplify_gen_binary (IOR, inner_mode, + simplify_gen_binary (AND, inner_mode, dest, negmask), or_mask)); } @@ -5796,15 +5799,18 @@ combine_simplify_rtx (rtx x, machine_mod return temp; /* If op is known to have all lower bits zero, the result is zero. */ + scalar_int_mode int_mode, int_op0_mode; if (!in_dest - && SCALAR_INT_MODE_P (mode) - && SCALAR_INT_MODE_P (op0_mode) - && GET_MODE_PRECISION (mode) < GET_MODE_PRECISION (op0_mode) - && subreg_lowpart_offset (mode, op0_mode) == SUBREG_BYTE (x) - && HWI_COMPUTABLE_MODE_P (op0_mode) - && (nonzero_bits (SUBREG_REG (x), op0_mode) - & GET_MODE_MASK (mode)) == 0) - return CONST0_RTX (mode); + && is_a (mode, &int_mode) + && is_a (op0_mode, &int_op0_mode) + && (GET_MODE_PRECISION (int_mode) + < GET_MODE_PRECISION (int_op0_mode)) + && (subreg_lowpart_offset (int_mode, int_op0_mode) + == SUBREG_BYTE (x)) + && HWI_COMPUTABLE_MODE_P (int_op0_mode) + && (nonzero_bits (SUBREG_REG (x), int_op0_mode) + & GET_MODE_MASK (int_mode)) == 0) + return CONST0_RTX (int_mode); } /* Don't change the mode of the MEM if that would change the meaning @@ -5912,12 +5918,13 @@ combine_simplify_rtx (rtx x, machine_mod sign_extract. The `and' may be a zero_extend and the two , - constants may be reversed. */ if (GET_CODE (XEXP (x, 0)) == XOR + && is_a (mode, &int_mode) && CONST_INT_P (XEXP (x, 1)) && CONST_INT_P (XEXP (XEXP (x, 0), 1)) && INTVAL (XEXP (x, 1)) == -INTVAL (XEXP (XEXP (x, 0), 1)) && ((i = exact_log2 (UINTVAL (XEXP (XEXP (x, 0), 1)))) >= 0 || (i = exact_log2 (UINTVAL (XEXP (x, 1)))) >= 0) - && HWI_COMPUTABLE_MODE_P (mode) + && HWI_COMPUTABLE_MODE_P (int_mode) && ((GET_CODE (XEXP (XEXP (x, 0), 0)) == AND && CONST_INT_P (XEXP (XEXP (XEXP (x, 0), 0), 1)) && (UINTVAL (XEXP (XEXP (XEXP (x, 0), 0), 1)) @@ -5926,11 +5933,11 @@ combine_simplify_rtx (rtx x, machine_mod && (GET_MODE_PRECISION (GET_MODE (XEXP (XEXP (XEXP (x, 0), 0), 0))) == (unsigned int) i + 1)))) return simplify_shift_const - (NULL_RTX, ASHIFTRT, mode, - simplify_shift_const (NULL_RTX, ASHIFT, mode, + (NULL_RTX, ASHIFTRT, int_mode, + simplify_shift_const (NULL_RTX, ASHIFT, int_mode, XEXP (XEXP (XEXP (x, 0), 0), 0), - GET_MODE_PRECISION (mode) - (i + 1)), - GET_MODE_PRECISION (mode) - (i + 1)); + GET_MODE_PRECISION (int_mode) - (i + 1)), + GET_MODE_PRECISION (int_mode) - (i + 1)); /* If only the low-order bit of X is possibly nonzero, (plus x -1) can become (ashiftrt (ashift (xor x 1) C) C) where C is @@ -6948,9 +6955,9 @@ simplify_set (rtx x) static rtx simplify_logical (rtx x) { - machine_mode mode = GET_MODE (x); rtx op0 = XEXP (x, 0); rtx op1 = XEXP (x, 1); + scalar_int_mode mode; switch (GET_CODE (x)) { @@ -6958,7 +6965,8 @@ simplify_logical (rtx x) /* We can call simplify_and_const_int only if we don't lose any (sign) bits when converting INTVAL (op1) to "unsigned HOST_WIDE_INT". */ - if (CONST_INT_P (op1) + if (is_a (GET_MODE (x), &mode) + && CONST_INT_P (op1) && (HWI_COMPUTABLE_MODE_P (mode) || INTVAL (op1) > 0)) { @@ -7033,6 +7041,7 @@ expand_compound_operation (rtx x) int unsignedp = 0; unsigned int modewidth; rtx tem; + scalar_int_mode inner_mode; switch (GET_CODE (x)) { @@ -7051,25 +7060,24 @@ expand_compound_operation (rtx x) if (CONST_INT_P (XEXP (x, 0))) return x; + /* Reject modes that aren't scalar integers because turning vector + or complex modes into shifts causes problems. */ + if (!is_a (GET_MODE (XEXP (x, 0)), &inner_mode)) + return x; + /* Return if (subreg:MODE FROM 0) is not a safe replacement for (zero_extend:MODE FROM) or (sign_extend:MODE FROM). It is for any MEM because (SUBREG (MEM...)) is guaranteed to cause the MEM to be reloaded. If not for that, MEM's would very rarely be safe. - Reject MODEs bigger than a word, because we might not be able + Reject modes bigger than a word, because we might not be able to reference a two-register group starting with an arbitrary register (and currently gen_lowpart might crash for a SUBREG). */ - if (GET_MODE_SIZE (GET_MODE (XEXP (x, 0))) > UNITS_PER_WORD) + if (GET_MODE_SIZE (inner_mode) > UNITS_PER_WORD) return x; - /* Reject MODEs that aren't scalar integers because turning vector - or complex modes into shifts causes problems. */ - - if (! SCALAR_INT_MODE_P (GET_MODE (XEXP (x, 0)))) - return x; - - len = GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))); + len = GET_MODE_PRECISION (inner_mode); /* If the inner object has VOIDmode (the only way this can happen is if it is an ASM_OPERANDS), we can't do anything since we don't know how much masking to do. */ @@ -7089,25 +7097,23 @@ expand_compound_operation (rtx x) return XEXP (x, 0); if (!CONST_INT_P (XEXP (x, 1)) - || !CONST_INT_P (XEXP (x, 2)) - || GET_MODE (XEXP (x, 0)) == VOIDmode) + || !CONST_INT_P (XEXP (x, 2))) return x; - /* Reject MODEs that aren't scalar integers because turning vector + /* Reject modes that aren't scalar integers because turning vector or complex modes into shifts causes problems. */ - - if (! SCALAR_INT_MODE_P (GET_MODE (XEXP (x, 0)))) + if (!is_a (GET_MODE (XEXP (x, 0)), &inner_mode)) return x; len = INTVAL (XEXP (x, 1)); pos = INTVAL (XEXP (x, 2)); /* This should stay within the object being extracted, fail otherwise. */ - if (len + pos > GET_MODE_PRECISION (GET_MODE (XEXP (x, 0)))) + if (len + pos > GET_MODE_PRECISION (inner_mode)) return x; if (BITS_BIG_ENDIAN) - pos = GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) - len - pos; + pos = GET_MODE_PRECISION (inner_mode) - len - pos; break; @@ -7118,12 +7124,10 @@ expand_compound_operation (rtx x) bit is not set, as this is easier to optimize. It will be converted back to cheaper alternative in make_extraction. */ if (GET_CODE (x) == SIGN_EXTEND - && (HWI_COMPUTABLE_MODE_P (GET_MODE (x)) - && ((nonzero_bits (XEXP (x, 0), GET_MODE (XEXP (x, 0))) - & ~(((unsigned HOST_WIDE_INT) - GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) - >> 1)) - == 0))) + && HWI_COMPUTABLE_MODE_P (GET_MODE (x)) + && ((nonzero_bits (XEXP (x, 0), inner_mode) + & ~(((unsigned HOST_WIDE_INT) GET_MODE_MASK (inner_mode)) >> 1)) + == 0)) { machine_mode mode = GET_MODE (x); rtx temp = gen_rtx_ZERO_EXTEND (mode, XEXP (x, 0)); @@ -7150,7 +7154,7 @@ expand_compound_operation (rtx x) && GET_MODE (XEXP (XEXP (x, 0), 0)) == GET_MODE (x) && HWI_COMPUTABLE_MODE_P (GET_MODE (x)) && (nonzero_bits (XEXP (XEXP (x, 0), 0), GET_MODE (x)) - & ~GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) == 0) + & ~GET_MODE_MASK (inner_mode)) == 0) return XEXP (XEXP (x, 0), 0); /* Likewise for (zero_extend:DI (subreg:SI foo:DI 0)). */ @@ -7159,7 +7163,7 @@ expand_compound_operation (rtx x) && subreg_lowpart_p (XEXP (x, 0)) && HWI_COMPUTABLE_MODE_P (GET_MODE (x)) && (nonzero_bits (SUBREG_REG (XEXP (x, 0)), GET_MODE (x)) - & ~GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) == 0) + & ~GET_MODE_MASK (inner_mode)) == 0) return SUBREG_REG (XEXP (x, 0)); /* (zero_extend:DI (truncate:SI foo:DI)) is just foo:DI when foo @@ -7169,9 +7173,8 @@ expand_compound_operation (rtx x) if (GET_CODE (XEXP (x, 0)) == TRUNCATE && GET_MODE (XEXP (XEXP (x, 0), 0)) == GET_MODE (x) && COMPARISON_P (XEXP (XEXP (x, 0), 0)) - && (GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) - <= HOST_BITS_PER_WIDE_INT) - && (STORE_FLAG_VALUE & ~GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) == 0) + && GET_MODE_PRECISION (inner_mode) <= HOST_BITS_PER_WIDE_INT + && (STORE_FLAG_VALUE & ~GET_MODE_MASK (inner_mode)) == 0) return XEXP (XEXP (x, 0), 0); /* Likewise for (zero_extend:DI (subreg:SI foo:DI 0)). */ @@ -7179,9 +7182,8 @@ expand_compound_operation (rtx x) && GET_MODE (SUBREG_REG (XEXP (x, 0))) == GET_MODE (x) && subreg_lowpart_p (XEXP (x, 0)) && COMPARISON_P (SUBREG_REG (XEXP (x, 0))) - && (GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) - <= HOST_BITS_PER_WIDE_INT) - && (STORE_FLAG_VALUE & ~GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) == 0) + && GET_MODE_PRECISION (inner_mode) <= HOST_BITS_PER_WIDE_INT + && (STORE_FLAG_VALUE & ~GET_MODE_MASK (inner_mode)) == 0) return SUBREG_REG (XEXP (x, 0)); } @@ -7246,7 +7248,7 @@ expand_field_assignment (const_rtx x) rtx pos; /* Always counts from low bit. */ int len; rtx mask, cleared, masked; - machine_mode compute_mode; + scalar_int_mode compute_mode; /* Loop until we find something we can't simplify. */ while (1) @@ -7314,17 +7316,15 @@ expand_field_assignment (const_rtx x) while (GET_CODE (inner) == SUBREG && subreg_lowpart_p (inner)) inner = SUBREG_REG (inner); - compute_mode = GET_MODE (inner); - /* Don't attempt bitwise arithmetic on non scalar integer modes. */ - if (! SCALAR_INT_MODE_P (compute_mode)) + if (!is_a (GET_MODE (inner), &compute_mode)) { /* Don't do anything for vector or complex integral types. */ - if (! FLOAT_MODE_P (compute_mode)) + if (! FLOAT_MODE_P (GET_MODE (inner))) break; /* Try to find an integral mode to pun with. */ - if (!int_mode_for_size (GET_MODE_BITSIZE (compute_mode), 0) + if (!int_mode_for_size (GET_MODE_BITSIZE (GET_MODE (inner)), 0) .exists (&compute_mode)) break; @@ -8274,10 +8274,11 @@ make_compound_operation (rtx x, enum rtx && XEXP (x, 1) == const0_rtx) ? COMPARE : in_code == COMPARE || in_code == EQ ? SET : in_code); - if (SCALAR_INT_MODE_P (GET_MODE (x))) + scalar_int_mode mode; + if (is_a (GET_MODE (x), &mode)) { - rtx new_rtx = make_compound_operation_int (GET_MODE (x), &x, - in_code, &next_code); + rtx new_rtx = make_compound_operation_int (mode, &x, in_code, + &next_code); if (new_rtx) return new_rtx; code = GET_CODE (x); @@ -10117,10 +10118,12 @@ extended_count (const_rtx x, machine_mod if (nonzero_sign_valid == 0) return 0; + scalar_int_mode int_mode; return (unsignedp - ? (HWI_COMPUTABLE_MODE_P (mode) - ? (unsigned int) (GET_MODE_PRECISION (mode) - 1 - - floor_log2 (nonzero_bits (x, mode))) + ? (is_a (mode, &int_mode) + && HWI_COMPUTABLE_MODE_P (int_mode) + ? (unsigned int) (GET_MODE_PRECISION (int_mode) - 1 + - floor_log2 (nonzero_bits (x, int_mode))) : 0) : num_sign_bit_copies (x, mode) - 1); } @@ -11290,7 +11293,9 @@ change_zero_ext (rtx pat) FOR_EACH_SUBRTX_PTR (iter, array, src, NONCONST) { rtx x = **iter; - machine_mode mode = GET_MODE (x); + scalar_int_mode mode; + if (!is_a (GET_MODE (x), &mode)) + continue; int size; if (GET_CODE (x) == ZERO_EXTRACT @@ -11316,7 +11321,6 @@ change_zero_ext (rtx pat) x = gen_lowpart_SUBREG (mode, x); } else if (GET_CODE (x) == ZERO_EXTEND - && SCALAR_INT_MODE_P (mode) && GET_CODE (XEXP (x, 0)) == SUBREG && SCALAR_INT_MODE_P (GET_MODE (SUBREG_REG (XEXP (x, 0)))) && !paradoxical_subreg_p (XEXP (x, 0)) @@ -11328,7 +11332,6 @@ change_zero_ext (rtx pat) x = gen_lowpart_SUBREG (mode, x); } else if (GET_CODE (x) == ZERO_EXTEND - && SCALAR_INT_MODE_P (mode) && REG_P (XEXP (x, 0)) && HARD_REGISTER_P (XEXP (x, 0)) && can_change_dest_mode (XEXP (x, 0), 0, mode)) @@ -12414,11 +12417,11 @@ simplify_comparison (enum rtx_code code, if (GET_CODE (XEXP (op0, 0)) == SUBREG && CONST_INT_P (XEXP (op0, 1))) { - tmode = GET_MODE (SUBREG_REG (XEXP (op0, 0))); unsigned HOST_WIDE_INT c1 = INTVAL (XEXP (op0, 1)); /* Require an integral mode, to avoid creating something like (AND:SF ...). */ - if (SCALAR_INT_MODE_P (tmode) + if ((is_a + (GET_MODE (SUBREG_REG (XEXP (op0, 0))), &tmode)) /* It is unsafe to commute the AND into the SUBREG if the SUBREG is paradoxical and WORD_REGISTER_OPERATIONS is not defined. As originally written the upper bits Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-07-13 09:18:31.696428597 +0100 +++ gcc/dwarf2out.c 2017-07-13 09:18:32.524353068 +0100 @@ -13944,7 +13944,7 @@ scompare_loc_descriptor_narrow (enum dwa return compare_loc_descriptor (op, op0, op1); } -/* Return location descriptor for signed comparison OP RTL. */ +/* Return location descriptor for unsigned comparison OP RTL. */ static dw_loc_descr_ref scompare_loc_descriptor (enum dwarf_location_atom op, rtx rtl, @@ -13958,10 +13958,11 @@ scompare_loc_descriptor (enum dwarf_loca if (op_mode == VOIDmode) return NULL; + scalar_int_mode int_op_mode; if (dwarf_strict && dwarf_version < 5 - && (!SCALAR_INT_MODE_P (op_mode) - || GET_MODE_SIZE (op_mode) > DWARF2_ADDR_SIZE)) + && (!is_a (op_mode, &int_op_mode) + || GET_MODE_SIZE (int_op_mode) > DWARF2_ADDR_SIZE)) return NULL; op0 = mem_loc_descriptor (XEXP (rtl, 0), op_mode, mem_mode, @@ -13972,13 +13973,13 @@ scompare_loc_descriptor (enum dwarf_loca if (op0 == NULL || op1 == NULL) return NULL; - if (SCALAR_INT_MODE_P (op_mode)) + if (is_a (op_mode, &int_op_mode)) { - if (GET_MODE_SIZE (op_mode) < DWARF2_ADDR_SIZE) - return scompare_loc_descriptor_narrow (op, rtl, op_mode, op0, op1); + if (GET_MODE_SIZE (int_op_mode) < DWARF2_ADDR_SIZE) + return scompare_loc_descriptor_narrow (op, rtl, int_op_mode, op0, op1); - if (GET_MODE_SIZE (op_mode) > DWARF2_ADDR_SIZE) - return scompare_loc_descriptor_wide (op, op_mode, op0, op1); + if (GET_MODE_SIZE (int_op_mode) > DWARF2_ADDR_SIZE) + return scompare_loc_descriptor_wide (op, int_op_mode, op0, op1); } return compare_loc_descriptor (op, op0, op1); } @@ -13989,14 +13990,14 @@ scompare_loc_descriptor (enum dwarf_loca ucompare_loc_descriptor (enum dwarf_location_atom op, rtx rtl, machine_mode mem_mode) { - machine_mode op_mode = GET_MODE (XEXP (rtl, 0)); dw_loc_descr_ref op0, op1; - if (op_mode == VOIDmode) - op_mode = GET_MODE (XEXP (rtl, 1)); - if (op_mode == VOIDmode) - return NULL; - if (!SCALAR_INT_MODE_P (op_mode)) + machine_mode test_op_mode = GET_MODE (XEXP (rtl, 0)); + if (test_op_mode == VOIDmode) + test_op_mode = GET_MODE (XEXP (rtl, 1)); + + scalar_int_mode op_mode; + if (!is_a (test_op_mode, &op_mode)) return NULL; if (dwarf_strict @@ -14064,10 +14065,11 @@ minmax_loc_descriptor (rtx rtl, machine_ dw_loc_descr_ref op0, op1, ret; dw_loc_descr_ref bra_node, drop_node; + scalar_int_mode int_mode; if (dwarf_strict && dwarf_version < 5 - && (!SCALAR_INT_MODE_P (mode) - || GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE)) + && (!is_a (mode, &int_mode) + || GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE)) return NULL; op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, @@ -14099,19 +14101,19 @@ minmax_loc_descriptor (rtx rtl, machine_ add_loc_descr (&op1, new_loc_descr (DW_OP_plus_uconst, bias, 0)); } } - else if (!SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) < DWARF2_ADDR_SIZE) + else if (is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) < DWARF2_ADDR_SIZE) { - int shift = (DWARF2_ADDR_SIZE - GET_MODE_SIZE (mode)) * BITS_PER_UNIT; + int shift = (DWARF2_ADDR_SIZE - GET_MODE_SIZE (int_mode)) * BITS_PER_UNIT; add_loc_descr (&op0, int_loc_descriptor (shift)); add_loc_descr (&op0, new_loc_descr (DW_OP_shl, 0, 0)); add_loc_descr (&op1, int_loc_descriptor (shift)); add_loc_descr (&op1, new_loc_descr (DW_OP_shl, 0, 0)); } - else if (SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) + else if (is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) { - dw_die_ref type_die = base_type_for_mode (mode, 0); + dw_die_ref type_die = base_type_for_mode (int_mode, 0); dw_loc_descr_ref cvt; if (type_die == NULL) return NULL; @@ -14142,9 +14144,9 @@ minmax_loc_descriptor (rtx rtl, machine_ bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc; bra_node->dw_loc_oprnd1.v.val_loc = drop_node; if ((GET_CODE (rtl) == SMIN || GET_CODE (rtl) == SMAX) - && SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) - ret = convert_descriptor_to_mode (mode, ret); + && is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) + ret = convert_descriptor_to_mode (int_mode, ret); return ret; } @@ -14605,6 +14607,7 @@ mem_loc_descriptor (rtx rtl, machine_mod if (mode != GET_MODE (rtl) && GET_MODE (rtl) != VOIDmode) return NULL; + scalar_int_mode int_mode, inner_mode; switch (GET_CODE (rtl)) { case POST_INC: @@ -14625,29 +14628,26 @@ mem_loc_descriptor (rtx rtl, machine_mod case TRUNCATE: if (inner == NULL_RTX) inner = XEXP (rtl, 0); - if (SCALAR_INT_MODE_P (mode) - && SCALAR_INT_MODE_P (GET_MODE (inner)) - && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE + if (is_a (mode, &int_mode) + && is_a (GET_MODE (inner), &inner_mode) + && (GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE #ifdef POINTERS_EXTEND_UNSIGNED - || (mode == Pmode && mem_mode != VOIDmode) + || (int_mode == Pmode && mem_mode != VOIDmode) #endif ) - && GET_MODE_SIZE (GET_MODE (inner)) <= DWARF2_ADDR_SIZE) + && GET_MODE_SIZE (inner_mode) <= DWARF2_ADDR_SIZE) { mem_loc_result = mem_loc_descriptor (inner, - GET_MODE (inner), + inner_mode, mem_mode, initialized); break; } if (dwarf_strict && dwarf_version < 5) break; - if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (inner))) - break; - if (GET_MODE_SIZE (mode) != GET_MODE_SIZE (GET_MODE (inner)) - && (!SCALAR_INT_MODE_P (mode) - || !SCALAR_INT_MODE_P (GET_MODE (inner)))) - break; - else + if (is_a (mode, &int_mode) + && is_a (GET_MODE (inner), &inner_mode) + ? GET_MODE_SIZE (int_mode) <= GET_MODE_SIZE (inner_mode) + : GET_MODE_SIZE (mode) == GET_MODE_SIZE (GET_MODE (inner))) { dw_die_ref type_die; dw_loc_descr_ref cvt; @@ -14672,8 +14672,8 @@ mem_loc_descriptor (rtx rtl, machine_mod cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; add_loc_descr (&mem_loc_result, cvt); - if (SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE) + if (is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE) { /* Convert it to untyped afterwards. */ cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0); @@ -14683,12 +14683,12 @@ mem_loc_descriptor (rtx rtl, machine_mod break; case REG: - if (! SCALAR_INT_MODE_P (mode) - || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE + if (!is_a (mode, &int_mode) + || (GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE && rtl != arg_pointer_rtx && rtl != frame_pointer_rtx #ifdef POINTERS_EXTEND_UNSIGNED - && (mode != Pmode || mem_mode == VOIDmode) + && (int_mode != Pmode || mem_mode == VOIDmode) #endif )) { @@ -14742,14 +14742,14 @@ mem_loc_descriptor (rtx rtl, machine_mod case SIGN_EXTEND: case ZERO_EXTEND: - if (!SCALAR_INT_MODE_P (mode)) + if (!is_a (mode, &int_mode)) break; op0 = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (XEXP (rtl, 0)), mem_mode, VAR_INIT_STATUS_INITIALIZED); if (op0 == 0) break; else if (GET_CODE (rtl) == ZERO_EXTEND - && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE + && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE && GET_MODE_BITSIZE (GET_MODE (XEXP (rtl, 0))) < HOST_BITS_PER_WIDE_INT /* If DW_OP_const{1,2,4}u won't be used, it is shorter @@ -14763,7 +14763,7 @@ mem_loc_descriptor (rtx rtl, machine_mod int_loc_descriptor (GET_MODE_MASK (imode))); add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_and, 0, 0)); } - else if (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE) + else if (GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE) { int shift = DWARF2_ADDR_SIZE - GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))); @@ -14787,7 +14787,7 @@ mem_loc_descriptor (rtx rtl, machine_mod GET_CODE (rtl) == ZERO_EXTEND); if (type_die1 == NULL) break; - type_die2 = base_type_for_mode (mode, 1); + type_die2 = base_type_for_mode (int_mode, 1); if (type_die2 == NULL) break; mem_loc_result = op0; @@ -14822,8 +14822,8 @@ mem_loc_descriptor (rtx rtl, machine_mod mem_loc_result = tls_mem_loc_descriptor (rtl); if (mem_loc_result != NULL) { - if (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE - || !SCALAR_INT_MODE_P(mode)) + if (!is_a (mode, &int_mode) + || GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) { dw_die_ref type_die; dw_loc_descr_ref deref; @@ -14841,12 +14841,12 @@ mem_loc_descriptor (rtx rtl, machine_mod deref->dw_loc_oprnd2.v.val_die_ref.external = 0; add_loc_descr (&mem_loc_result, deref); } - else if (GET_MODE_SIZE (mode) == DWARF2_ADDR_SIZE) + else if (GET_MODE_SIZE (int_mode) == DWARF2_ADDR_SIZE) add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0)); else add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref_size, - GET_MODE_SIZE (mode), 0)); + GET_MODE_SIZE (int_mode), 0)); } break; @@ -14859,10 +14859,10 @@ mem_loc_descriptor (rtx rtl, machine_mod pool. */ case CONST: case SYMBOL_REF: - if (!SCALAR_INT_MODE_P (mode) - || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE + if (!is_a (mode, &int_mode) + || (GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE #ifdef POINTERS_EXTEND_UNSIGNED - && (mode != Pmode || mem_mode == VOIDmode) + && (int_mode != Pmode || mem_mode == VOIDmode) #endif )) break; @@ -14891,8 +14891,8 @@ mem_loc_descriptor (rtx rtl, machine_mod if (!const_ok_for_output (rtl)) { if (GET_CODE (rtl) == CONST) - mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, - initialized); + mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), int_mode, + mem_mode, initialized); break; } @@ -14914,8 +14914,8 @@ mem_loc_descriptor (rtx rtl, machine_mod return NULL; if (REG_P (ENTRY_VALUE_EXP (rtl))) { - if (!SCALAR_INT_MODE_P (mode) - || GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) + if (!is_a (mode, &int_mode) + || GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) op0 = mem_loc_descriptor (ENTRY_VALUE_EXP (rtl), mode, VOIDmode, VAR_INIT_STATUS_INITIALIZED); else @@ -14969,10 +14969,10 @@ mem_loc_descriptor (rtx rtl, machine_mod case PLUS: plus: if (is_based_loc (rtl) - && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE + && is_a (mode, &int_mode) + && (GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE || XEXP (rtl, 0) == arg_pointer_rtx - || XEXP (rtl, 0) == frame_pointer_rtx) - && SCALAR_INT_MODE_P (mode)) + || XEXP (rtl, 0) == frame_pointer_rtx)) mem_loc_result = based_loc_descr (XEXP (rtl, 0), INTVAL (XEXP (rtl, 1)), VAR_INIT_STATUS_INITIALIZED); @@ -15011,12 +15011,12 @@ mem_loc_descriptor (rtx rtl, machine_mod case DIV: if ((!dwarf_strict || dwarf_version >= 5) - && SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) + && is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) { mem_loc_result = typed_binop (DW_OP_div, rtl, base_type_for_mode (mode, 0), - mode, mem_mode); + int_mode, mem_mode); break; } op = DW_OP_div; @@ -15039,17 +15039,17 @@ mem_loc_descriptor (rtx rtl, machine_mod goto do_shift; do_shift: - if (!SCALAR_INT_MODE_P (mode)) + if (!is_a (mode, &int_mode)) break; - op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, + op0 = mem_loc_descriptor (XEXP (rtl, 0), int_mode, mem_mode, VAR_INIT_STATUS_INITIALIZED); { rtx rtlop1 = XEXP (rtl, 1); if (GET_MODE (rtlop1) != VOIDmode && GET_MODE_BITSIZE (GET_MODE (rtlop1)) - < GET_MODE_BITSIZE (mode)) - rtlop1 = gen_rtx_ZERO_EXTEND (mode, rtlop1); - op1 = mem_loc_descriptor (rtlop1, mode, mem_mode, + < GET_MODE_BITSIZE (int_mode)) + rtlop1 = gen_rtx_ZERO_EXTEND (int_mode, rtlop1); + op1 = mem_loc_descriptor (rtlop1, int_mode, mem_mode, VAR_INIT_STATUS_INITIALIZED); } @@ -15116,16 +15116,16 @@ mem_loc_descriptor (rtx rtl, machine_mod case UDIV: if ((!dwarf_strict || dwarf_version >= 5) - && SCALAR_INT_MODE_P (mode)) + && is_a (mode, &int_mode)) { - if (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) + if (GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) { op = DW_OP_div; goto do_binop; } mem_loc_result = typed_binop (DW_OP_div, rtl, - base_type_for_mode (mode, 1), - mode, mem_mode); + base_type_for_mode (int_mode, 1), + int_mode, mem_mode); } break; @@ -15153,9 +15153,10 @@ mem_loc_descriptor (rtx rtl, machine_mod break; case CONST_INT: - if (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE + if (!is_a (mode, &int_mode) + || GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE #ifdef POINTERS_EXTEND_UNSIGNED - || (mode == Pmode + || (int_mode == Pmode && mem_mode != VOIDmode && trunc_int_for_mode (INTVAL (rtl), ptr_mode) == INTVAL (rtl)) #endif @@ -15165,10 +15166,10 @@ mem_loc_descriptor (rtx rtl, machine_mod break; } if ((!dwarf_strict || dwarf_version >= 5) - && (GET_MODE_BITSIZE (mode) == HOST_BITS_PER_WIDE_INT - || GET_MODE_BITSIZE (mode) == HOST_BITS_PER_DOUBLE_INT)) + && (GET_MODE_BITSIZE (int_mode) == HOST_BITS_PER_WIDE_INT + || GET_MODE_BITSIZE (int_mode) == HOST_BITS_PER_DOUBLE_INT)) { - dw_die_ref type_die = base_type_for_mode (mode, 1); + dw_die_ref type_die = base_type_for_mode (int_mode, 1); scalar_int_mode amode; if (type_die == NULL) return NULL; @@ -15179,7 +15180,7 @@ mem_loc_descriptor (rtx rtl, machine_mod /* const DW_OP_convert vs. DW_OP_const_type . */ && size_of_int_loc_descriptor (INTVAL (rtl)) + 1 + 1 - < (unsigned long) 1 + 1 + 1 + GET_MODE_SIZE (mode)) + < (unsigned long) 1 + 1 + 1 + GET_MODE_SIZE (int_mode)) { mem_loc_result = int_loc_descriptor (INTVAL (rtl)); op0 = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0); @@ -15194,7 +15195,7 @@ mem_loc_descriptor (rtx rtl, machine_mod mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_die_ref; mem_loc_result->dw_loc_oprnd1.v.val_die_ref.die = type_die; mem_loc_result->dw_loc_oprnd1.v.val_die_ref.external = 0; - if (GET_MODE_BITSIZE (mode) == HOST_BITS_PER_WIDE_INT) + if (GET_MODE_BITSIZE (int_mode) == HOST_BITS_PER_WIDE_INT) mem_loc_result->dw_loc_oprnd2.val_class = dw_val_class_const; else { @@ -15327,11 +15328,11 @@ mem_loc_descriptor (rtx rtl, machine_mod case SIGN_EXTRACT: if (CONST_INT_P (XEXP (rtl, 1)) && CONST_INT_P (XEXP (rtl, 2)) + && is_a (mode, &int_mode) && ((unsigned) INTVAL (XEXP (rtl, 1)) + (unsigned) INTVAL (XEXP (rtl, 2)) - <= GET_MODE_BITSIZE (mode)) - && SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE + <= GET_MODE_BITSIZE (int_mode)) + && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE && GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))) <= DWARF2_ADDR_SIZE) { int shift, size; @@ -15407,12 +15408,11 @@ mem_loc_descriptor (rtx rtl, machine_mod mem_mode, VAR_INIT_STATUS_INITIALIZED); if (op0 == NULL) break; - if (SCALAR_INT_MODE_P (GET_MODE (XEXP (rtl, 0))) + if (is_a (GET_MODE (XEXP (rtl, 0)), &int_mode) && (GET_CODE (rtl) == FLOAT - || GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))) - <= DWARF2_ADDR_SIZE)) + || GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE)) { - type_die = base_type_for_mode (GET_MODE (XEXP (rtl, 0)), + type_die = base_type_for_mode (int_mode, GET_CODE (rtl) == UNSIGNED_FLOAT); if (type_die == NULL) break; @@ -15430,11 +15430,11 @@ mem_loc_descriptor (rtx rtl, machine_mod cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; add_loc_descr (&op0, cvt); - if (SCALAR_INT_MODE_P (mode) + if (is_a (mode, &int_mode) && (GET_CODE (rtl) == FIX - || GET_MODE_SIZE (mode) < DWARF2_ADDR_SIZE)) + || GET_MODE_SIZE (int_mode) < DWARF2_ADDR_SIZE)) { - op0 = convert_descriptor_to_mode (mode, op0); + op0 = convert_descriptor_to_mode (int_mode, op0); if (op0 == NULL) break; } @@ -15675,6 +15675,7 @@ loc_descriptor (rtx rtl, machine_mode mo enum var_init_status initialized) { dw_loc_descr_ref loc_result = NULL; + scalar_int_mode int_mode; switch (GET_CODE (rtl)) { @@ -15901,9 +15902,9 @@ loc_descriptor (rtx rtl, machine_mode mo /* FALLTHRU */ do_default: default: - if ((SCALAR_INT_MODE_P (mode) - && GET_MODE (rtl) == mode - && GET_MODE_SIZE (GET_MODE (rtl)) <= DWARF2_ADDR_SIZE + if ((is_a (mode, &int_mode) + && GET_MODE (rtl) == int_mode + && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE && dwarf_version >= 4) || (!dwarf_strict && mode != VOIDmode && mode != BLKmode)) { Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:31.696428597 +0100 +++ gcc/expmed.c 2017-07-13 09:18:32.525352977 +0100 @@ -202,14 +202,15 @@ init_expmed_one_mode (struct init_expmed speed)); } - if (SCALAR_INT_MODE_P (mode)) + scalar_int_mode int_mode_to; + if (is_a (mode, &int_mode_to)) { FOR_EACH_MODE_IN_CLASS (mode_from, MODE_INT) - init_expmed_one_conv (all, mode, mode_from, speed); + init_expmed_one_conv (all, int_mode_to, mode_from, speed); - machine_mode wider_mode; - if (GET_MODE_CLASS (mode) == MODE_INT - && GET_MODE_WIDER_MODE (mode).exists (&wider_mode)) + scalar_int_mode wider_mode; + if (GET_MODE_CLASS (int_mode_to) == MODE_INT + && GET_MODE_WIDER_MODE (int_mode_to).exists (&wider_mode)) { PUT_MODE (all->zext, wider_mode); PUT_MODE (all->wide_mult, wider_mode); @@ -218,8 +219,9 @@ init_expmed_one_mode (struct init_expmed set_mul_widen_cost (speed, wider_mode, set_src_cost (all->wide_mult, wider_mode, speed)); - set_mul_highpart_cost (speed, mode, - set_src_cost (all->wide_trunc, mode, speed)); + set_mul_highpart_cost (speed, int_mode_to, + set_src_cost (all->wide_trunc, + int_mode_to, speed)); } } } Index: gcc/lra-constraints.c =================================================================== --- gcc/lra-constraints.c 2017-07-05 16:29:19.599861904 +0100 +++ gcc/lra-constraints.c 2017-07-13 09:18:32.526352886 +0100 @@ -671,8 +671,11 @@ ok_for_base_p_nonstrict (rtx reg, machin lra_constraint_offset (int regno, machine_mode mode) { lra_assert (regno < FIRST_PSEUDO_REGISTER); - if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (mode) > UNITS_PER_WORD - && SCALAR_INT_MODE_P (mode)) + + scalar_int_mode int_mode; + if (WORDS_BIG_ENDIAN + && is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > UNITS_PER_WORD) return hard_regno_nregs[regno][mode] - 1; return 0; } Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:31.700428230 +0100 +++ gcc/optabs.c 2017-07-13 09:18:32.526352886 +0100 @@ -4996,9 +4996,9 @@ expand_fix (rtx to, rtx from, int unsign static rtx prepare_libcall_arg (rtx arg, int uintp) { - machine_mode mode = GET_MODE (arg); + scalar_int_mode mode; machine_mode arg_mode; - if (SCALAR_INT_MODE_P (mode)) + if (is_a (GET_MODE (arg), &mode)) { /* If we need to promote the integer function argument we need to do it here instead of inside emit_library_call_value because in Index: gcc/postreload.c =================================================================== --- gcc/postreload.c 2017-07-13 09:18:21.535428823 +0100 +++ gcc/postreload.c 2017-07-13 09:18:32.527352795 +0100 @@ -2154,7 +2154,7 @@ move2add_note_store (rtx dst, const_rtx { rtx_insn *insn = (rtx_insn *) data; unsigned int regno = 0; - machine_mode mode = GET_MODE (dst); + scalar_int_mode mode; /* Some targets do argument pushes without adding REG_INC notes. */ @@ -2174,8 +2174,10 @@ move2add_note_store (rtx dst, const_rtx else return; - if (SCALAR_INT_MODE_P (mode) - && GET_CODE (set) == SET) + if (!is_a (GET_MODE (dst), &mode)) + goto invalidate; + + if (GET_CODE (set) == SET) { rtx note, sym = NULL_RTX; rtx off; @@ -2202,8 +2204,7 @@ move2add_note_store (rtx dst, const_rtx } } - if (SCALAR_INT_MODE_P (mode) - && GET_CODE (set) == SET + if (GET_CODE (set) == SET && GET_CODE (SET_DEST (set)) != ZERO_EXTRACT && GET_CODE (SET_DEST (set)) != STRICT_LOW_PART) { Index: gcc/reload.c =================================================================== --- gcc/reload.c 2017-03-28 16:19:20.000000000 +0100 +++ gcc/reload.c 2017-07-13 09:18:32.527352795 +0100 @@ -2264,14 +2264,18 @@ operands_match_p (rtx x, rtx y) multiple hard register group of scalar integer registers, so that for example (reg:DI 0) and (reg:SI 1) will be considered the same register. */ - if (REG_WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD - && SCALAR_INT_MODE_P (GET_MODE (x)) + scalar_int_mode xmode; + if (REG_WORDS_BIG_ENDIAN + && is_a (GET_MODE (x), &xmode) + && GET_MODE_SIZE (xmode) > UNITS_PER_WORD && i < FIRST_PSEUDO_REGISTER) - i += hard_regno_nregs[i][GET_MODE (x)] - 1; - if (REG_WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (y)) > UNITS_PER_WORD - && SCALAR_INT_MODE_P (GET_MODE (y)) + i += hard_regno_nregs[i][xmode] - 1; + scalar_int_mode ymode; + if (REG_WORDS_BIG_ENDIAN + && is_a (GET_MODE (y), &ymode) + && GET_MODE_SIZE (ymode) > UNITS_PER_WORD && j < FIRST_PSEUDO_REGISTER) - j += hard_regno_nregs[j][GET_MODE (y)] - 1; + j += hard_regno_nregs[j][ymode] - 1; return i == j; } Index: gcc/rtl.h =================================================================== --- gcc/rtl.h 2017-07-02 10:05:20.997439436 +0100 +++ gcc/rtl.h 2017-07-13 09:18:32.528352705 +0100 @@ -3822,9 +3822,10 @@ struct GTY(()) cgraph_rtl_info { inline rtx_code load_extend_op (machine_mode mode) { - if (SCALAR_INT_MODE_P (mode) - && GET_MODE_PRECISION (mode) < BITS_PER_WORD) - return LOAD_EXTEND_OP (mode); + scalar_int_mode int_mode; + if (is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) < BITS_PER_WORD) + return LOAD_EXTEND_OP (int_mode); return UNKNOWN; } Index: gcc/rtlhooks.c =================================================================== --- gcc/rtlhooks.c 2017-02-23 19:54:03.000000000 +0000 +++ gcc/rtlhooks.c 2017-07-13 09:18:32.528352705 +0100 @@ -64,11 +64,12 @@ gen_lowpart_general (machine_mode mode, gcc_assert (MEM_P (x)); /* The following exposes the use of "x" to CSE. */ - if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD - && SCALAR_INT_MODE_P (GET_MODE (x)) - && TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (x)) + scalar_int_mode xmode; + if (is_a (GET_MODE (x), &xmode) + && GET_MODE_SIZE (xmode) <= UNITS_PER_WORD + && TRULY_NOOP_TRUNCATION_MODES_P (mode, xmode) && !reload_completed) - return gen_lowpart_general (mode, force_reg (GET_MODE (x), x)); + return gen_lowpart_general (mode, force_reg (xmode, x)); if (WORDS_BIG_ENDIAN) offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD) Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:31.701428138 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:32.529352614 +0100 @@ -641,6 +641,8 @@ simplify_truncation (machine_mode mode, { unsigned int precision = GET_MODE_UNIT_PRECISION (mode); unsigned int op_precision = GET_MODE_UNIT_PRECISION (op_mode); + scalar_int_mode int_mode, int_op_mode, subreg_mode; + gcc_assert (precision <= op_precision); /* Optimize truncations of zero and sign extended values. */ @@ -806,19 +808,19 @@ simplify_truncation (machine_mode mode, if the MEM has a mode-dependent address. */ if ((GET_CODE (op) == LSHIFTRT || GET_CODE (op) == ASHIFTRT) - && SCALAR_INT_MODE_P (op_mode) + && is_a (op_mode, &int_op_mode) && MEM_P (XEXP (op, 0)) && CONST_INT_P (XEXP (op, 1)) && (INTVAL (XEXP (op, 1)) % GET_MODE_BITSIZE (mode)) == 0 && INTVAL (XEXP (op, 1)) > 0 - && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (op_mode) + && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (int_op_mode) && ! mode_dependent_address_p (XEXP (XEXP (op, 0), 0), MEM_ADDR_SPACE (XEXP (op, 0))) && ! MEM_VOLATILE_P (XEXP (op, 0)) && (GET_MODE_SIZE (mode) >= UNITS_PER_WORD || WORDS_BIG_ENDIAN == BYTES_BIG_ENDIAN)) { - int byte = subreg_lowpart_offset (mode, op_mode); + int byte = subreg_lowpart_offset (mode, int_op_mode); int shifted_bytes = INTVAL (XEXP (op, 1)) / BITS_PER_UNIT; return adjust_address_nv (XEXP (op, 0), mode, (WORDS_BIG_ENDIAN @@ -839,21 +841,20 @@ simplify_truncation (machine_mode mode, /* (truncate:A (subreg:B (truncate:C X) 0)) is (truncate:A X). */ if (GET_CODE (op) == SUBREG - && SCALAR_INT_MODE_P (mode) + && is_a (mode, &int_mode) && SCALAR_INT_MODE_P (op_mode) - && SCALAR_INT_MODE_P (GET_MODE (SUBREG_REG (op))) + && is_a (GET_MODE (SUBREG_REG (op)), &subreg_mode) && GET_CODE (SUBREG_REG (op)) == TRUNCATE && subreg_lowpart_p (op)) { rtx inner = XEXP (SUBREG_REG (op), 0); - if (GET_MODE_PRECISION (mode) - <= GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op)))) - return simplify_gen_unary (TRUNCATE, mode, inner, GET_MODE (inner)); + if (GET_MODE_PRECISION (int_mode) <= GET_MODE_PRECISION (subreg_mode)) + return simplify_gen_unary (TRUNCATE, int_mode, inner, + GET_MODE (inner)); else /* If subreg above is paradoxical and C is narrower than A, return (subreg:A (truncate:C X) 0). */ - return simplify_gen_subreg (mode, SUBREG_REG (op), - GET_MODE (SUBREG_REG (op)), 0); + return simplify_gen_subreg (int_mode, SUBREG_REG (op), subreg_mode, 0); } /* (truncate:A (truncate:B X)) is (truncate:A X). */ @@ -915,6 +916,7 @@ simplify_unary_operation_1 (enum rtx_cod { enum rtx_code reversed; rtx temp; + scalar_int_mode inner; switch (code) { @@ -1147,9 +1149,8 @@ simplify_unary_operation_1 (enum rtx_cod /* (neg (lt x 0)) is (lshiftrt X C) if STORE_FLAG_VALUE is -1. */ if (GET_CODE (op) == LT && XEXP (op, 1) == const0_rtx - && SCALAR_INT_MODE_P (GET_MODE (XEXP (op, 0)))) + && is_a (GET_MODE (XEXP (op, 0)), &inner)) { - machine_mode inner = GET_MODE (XEXP (op, 0)); int isize = GET_MODE_PRECISION (inner); if (STORE_FLAG_VALUE == 1) { @@ -2128,6 +2129,7 @@ simplify_binary_operation_1 (enum rtx_co rtx tem, reversed, opleft, opright; HOST_WIDE_INT val; unsigned int width = GET_MODE_PRECISION (mode); + scalar_int_mode int_mode; /* Even if we can't compute a constant result, there are some cases worth simplifying. */ @@ -2178,66 +2180,66 @@ simplify_binary_operation_1 (enum rtx_co have X (if C is 2 in the example above). But don't make something more expensive than we had before. */ - if (SCALAR_INT_MODE_P (mode)) + if (is_a (mode, &int_mode)) { rtx lhs = op0, rhs = op1; - wide_int coeff0 = wi::one (GET_MODE_PRECISION (mode)); - wide_int coeff1 = wi::one (GET_MODE_PRECISION (mode)); + wide_int coeff0 = wi::one (GET_MODE_PRECISION (int_mode)); + wide_int coeff1 = wi::one (GET_MODE_PRECISION (int_mode)); if (GET_CODE (lhs) == NEG) { - coeff0 = wi::minus_one (GET_MODE_PRECISION (mode)); + coeff0 = wi::minus_one (GET_MODE_PRECISION (int_mode)); lhs = XEXP (lhs, 0); } else if (GET_CODE (lhs) == MULT && CONST_SCALAR_INT_P (XEXP (lhs, 1))) { - coeff0 = rtx_mode_t (XEXP (lhs, 1), mode); + coeff0 = rtx_mode_t (XEXP (lhs, 1), int_mode); lhs = XEXP (lhs, 0); } else if (GET_CODE (lhs) == ASHIFT && CONST_INT_P (XEXP (lhs, 1)) && INTVAL (XEXP (lhs, 1)) >= 0 - && INTVAL (XEXP (lhs, 1)) < GET_MODE_PRECISION (mode)) + && INTVAL (XEXP (lhs, 1)) < GET_MODE_PRECISION (int_mode)) { coeff0 = wi::set_bit_in_zero (INTVAL (XEXP (lhs, 1)), - GET_MODE_PRECISION (mode)); + GET_MODE_PRECISION (int_mode)); lhs = XEXP (lhs, 0); } if (GET_CODE (rhs) == NEG) { - coeff1 = wi::minus_one (GET_MODE_PRECISION (mode)); + coeff1 = wi::minus_one (GET_MODE_PRECISION (int_mode)); rhs = XEXP (rhs, 0); } else if (GET_CODE (rhs) == MULT && CONST_INT_P (XEXP (rhs, 1))) { - coeff1 = rtx_mode_t (XEXP (rhs, 1), mode); + coeff1 = rtx_mode_t (XEXP (rhs, 1), int_mode); rhs = XEXP (rhs, 0); } else if (GET_CODE (rhs) == ASHIFT && CONST_INT_P (XEXP (rhs, 1)) && INTVAL (XEXP (rhs, 1)) >= 0 - && INTVAL (XEXP (rhs, 1)) < GET_MODE_PRECISION (mode)) + && INTVAL (XEXP (rhs, 1)) < GET_MODE_PRECISION (int_mode)) { coeff1 = wi::set_bit_in_zero (INTVAL (XEXP (rhs, 1)), - GET_MODE_PRECISION (mode)); + GET_MODE_PRECISION (int_mode)); rhs = XEXP (rhs, 0); } if (rtx_equal_p (lhs, rhs)) { - rtx orig = gen_rtx_PLUS (mode, op0, op1); + rtx orig = gen_rtx_PLUS (int_mode, op0, op1); rtx coeff; bool speed = optimize_function_for_speed_p (cfun); - coeff = immed_wide_int_const (coeff0 + coeff1, mode); + coeff = immed_wide_int_const (coeff0 + coeff1, int_mode); - tem = simplify_gen_binary (MULT, mode, lhs, coeff); - return (set_src_cost (tem, mode, speed) - <= set_src_cost (orig, mode, speed) ? tem : 0); + tem = simplify_gen_binary (MULT, int_mode, lhs, coeff); + return (set_src_cost (tem, int_mode, speed) + <= set_src_cost (orig, int_mode, speed) ? tem : 0); } } @@ -2355,67 +2357,67 @@ simplify_binary_operation_1 (enum rtx_co have X (if C is 2 in the example above). But don't make something more expensive than we had before. */ - if (SCALAR_INT_MODE_P (mode)) + if (is_a (mode, &int_mode)) { rtx lhs = op0, rhs = op1; - wide_int coeff0 = wi::one (GET_MODE_PRECISION (mode)); - wide_int negcoeff1 = wi::minus_one (GET_MODE_PRECISION (mode)); + wide_int coeff0 = wi::one (GET_MODE_PRECISION (int_mode)); + wide_int negcoeff1 = wi::minus_one (GET_MODE_PRECISION (int_mode)); if (GET_CODE (lhs) == NEG) { - coeff0 = wi::minus_one (GET_MODE_PRECISION (mode)); + coeff0 = wi::minus_one (GET_MODE_PRECISION (int_mode)); lhs = XEXP (lhs, 0); } else if (GET_CODE (lhs) == MULT && CONST_SCALAR_INT_P (XEXP (lhs, 1))) { - coeff0 = rtx_mode_t (XEXP (lhs, 1), mode); + coeff0 = rtx_mode_t (XEXP (lhs, 1), int_mode); lhs = XEXP (lhs, 0); } else if (GET_CODE (lhs) == ASHIFT && CONST_INT_P (XEXP (lhs, 1)) && INTVAL (XEXP (lhs, 1)) >= 0 - && INTVAL (XEXP (lhs, 1)) < GET_MODE_PRECISION (mode)) + && INTVAL (XEXP (lhs, 1)) < GET_MODE_PRECISION (int_mode)) { coeff0 = wi::set_bit_in_zero (INTVAL (XEXP (lhs, 1)), - GET_MODE_PRECISION (mode)); + GET_MODE_PRECISION (int_mode)); lhs = XEXP (lhs, 0); } if (GET_CODE (rhs) == NEG) { - negcoeff1 = wi::one (GET_MODE_PRECISION (mode)); + negcoeff1 = wi::one (GET_MODE_PRECISION (int_mode)); rhs = XEXP (rhs, 0); } else if (GET_CODE (rhs) == MULT && CONST_INT_P (XEXP (rhs, 1))) { - negcoeff1 = wi::neg (rtx_mode_t (XEXP (rhs, 1), mode)); + negcoeff1 = wi::neg (rtx_mode_t (XEXP (rhs, 1), int_mode)); rhs = XEXP (rhs, 0); } else if (GET_CODE (rhs) == ASHIFT && CONST_INT_P (XEXP (rhs, 1)) && INTVAL (XEXP (rhs, 1)) >= 0 - && INTVAL (XEXP (rhs, 1)) < GET_MODE_PRECISION (mode)) + && INTVAL (XEXP (rhs, 1)) < GET_MODE_PRECISION (int_mode)) { negcoeff1 = wi::set_bit_in_zero (INTVAL (XEXP (rhs, 1)), - GET_MODE_PRECISION (mode)); + GET_MODE_PRECISION (int_mode)); negcoeff1 = -negcoeff1; rhs = XEXP (rhs, 0); } if (rtx_equal_p (lhs, rhs)) { - rtx orig = gen_rtx_MINUS (mode, op0, op1); + rtx orig = gen_rtx_MINUS (int_mode, op0, op1); rtx coeff; bool speed = optimize_function_for_speed_p (cfun); - coeff = immed_wide_int_const (coeff0 + negcoeff1, mode); + coeff = immed_wide_int_const (coeff0 + negcoeff1, int_mode); - tem = simplify_gen_binary (MULT, mode, lhs, coeff); - return (set_src_cost (tem, mode, speed) - <= set_src_cost (orig, mode, speed) ? tem : 0); + tem = simplify_gen_binary (MULT, int_mode, lhs, coeff); + return (set_src_cost (tem, int_mode, speed) + <= set_src_cost (orig, int_mode, speed) ? tem : 0); } } @@ -3890,8 +3892,6 @@ simplify_binary_operation_1 (enum rtx_co simplify_const_binary_operation (enum rtx_code code, machine_mode mode, rtx op0, rtx op1) { - unsigned int width = GET_MODE_PRECISION (mode); - if (VECTOR_MODE_P (mode) && code != VEC_CONCAT && GET_CODE (op0) == CONST_VECTOR @@ -4085,15 +4085,15 @@ simplify_const_binary_operation (enum rt } /* We can fold some multi-word operations. */ - if ((GET_MODE_CLASS (mode) == MODE_INT - || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT) + scalar_int_mode int_mode; + if (is_a (mode, &int_mode) && CONST_SCALAR_INT_P (op0) && CONST_SCALAR_INT_P (op1)) { wide_int result; bool overflow; - rtx_mode_t pop0 = rtx_mode_t (op0, mode); - rtx_mode_t pop1 = rtx_mode_t (op1, mode); + rtx_mode_t pop0 = rtx_mode_t (op0, int_mode); + rtx_mode_t pop1 = rtx_mode_t (op1, int_mode); #if TARGET_SUPPORTS_WIDE_INT == 0 /* This assert keeps the simplification from producing a result @@ -4102,7 +4102,7 @@ simplify_const_binary_operation (enum rt simplify something and so you if you added this to the test above the code would die later anyway. If this assert happens, you just need to make the port support wide int. */ - gcc_assert (width <= HOST_BITS_PER_DOUBLE_INT); + gcc_assert (GET_MODE_PRECISION (int_mode) <= HOST_BITS_PER_DOUBLE_INT); #endif switch (code) { @@ -4176,8 +4176,8 @@ simplify_const_binary_operation (enum rt { wide_int wop1 = pop1; if (SHIFT_COUNT_TRUNCATED) - wop1 = wi::umod_trunc (wop1, width); - else if (wi::geu_p (wop1, width)) + wop1 = wi::umod_trunc (wop1, GET_MODE_PRECISION (int_mode)); + else if (wi::geu_p (wop1, GET_MODE_PRECISION (int_mode))) return NULL_RTX; switch (code) @@ -4223,7 +4223,7 @@ simplify_const_binary_operation (enum rt default: return NULL_RTX; } - return immed_wide_int_const (result, mode); + return immed_wide_int_const (result, int_mode); } return NULL_RTX; @@ -5145,12 +5145,14 @@ simplify_const_relational_operation (enu } /* Optimize comparisons with upper and lower bounds. */ - if (HWI_COMPUTABLE_MODE_P (mode) - && CONST_INT_P (trueop1) + scalar_int_mode int_mode; + if (CONST_INT_P (trueop1) + && is_a (mode, &int_mode) + && HWI_COMPUTABLE_MODE_P (int_mode) && !side_effects_p (trueop0)) { int sign; - unsigned HOST_WIDE_INT nonzero = nonzero_bits (trueop0, mode); + unsigned HOST_WIDE_INT nonzero = nonzero_bits (trueop0, int_mode); HOST_WIDE_INT val = INTVAL (trueop1); HOST_WIDE_INT mmin, mmax; @@ -5163,7 +5165,7 @@ simplify_const_relational_operation (enu sign = 1; /* Get a reduced range if the sign bit is zero. */ - if (nonzero <= (GET_MODE_MASK (mode) >> 1)) + if (nonzero <= (GET_MODE_MASK (int_mode) >> 1)) { mmin = 0; mmax = nonzero; @@ -5171,13 +5173,14 @@ simplify_const_relational_operation (enu else { rtx mmin_rtx, mmax_rtx; - get_mode_bounds (mode, sign, mode, &mmin_rtx, &mmax_rtx); + get_mode_bounds (int_mode, sign, int_mode, &mmin_rtx, &mmax_rtx); mmin = INTVAL (mmin_rtx); mmax = INTVAL (mmax_rtx); if (sign) { - unsigned int sign_copies = num_sign_bit_copies (trueop0, mode); + unsigned int sign_copies + = num_sign_bit_copies (trueop0, int_mode); mmin >>= (sign_copies - 1); mmax >>= (sign_copies - 1); @@ -6229,12 +6232,14 @@ simplify_subreg (machine_mode outermode, return CONST0_RTX (outermode); } - if (SCALAR_INT_MODE_P (outermode) - && SCALAR_INT_MODE_P (innermode) - && GET_MODE_PRECISION (outermode) < GET_MODE_PRECISION (innermode) - && byte == subreg_lowpart_offset (outermode, innermode)) + scalar_int_mode int_outermode, int_innermode; + if (is_a (outermode, &int_outermode) + && is_a (innermode, &int_innermode) + && (GET_MODE_PRECISION (int_outermode) + < GET_MODE_PRECISION (int_innermode)) + && byte == subreg_lowpart_offset (int_outermode, int_innermode)) { - rtx tem = simplify_truncation (outermode, op, innermode); + rtx tem = simplify_truncation (int_outermode, op, int_innermode); if (tem) return tem; } Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:31.701428138 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:32.529352614 +0100 @@ -412,8 +412,10 @@ bitwise_mode_for_mode (machine_mode mode { /* Quick exit if we already have a suitable mode. */ unsigned int bitsize = GET_MODE_BITSIZE (mode); - if (SCALAR_INT_MODE_P (mode) && bitsize <= MAX_FIXED_MODE_SIZE) - return mode; + scalar_int_mode int_mode; + if (is_a (mode, &int_mode) + && GET_MODE_BITSIZE (int_mode) <= MAX_FIXED_MODE_SIZE) + return int_mode; /* Reuse the sanity checks from int_mode_for_mode. */ gcc_checking_assert ((int_mode_for_mode (mode), true)); Index: gcc/var-tracking.c =================================================================== --- gcc/var-tracking.c 2017-07-13 09:18:30.093576660 +0100 +++ gcc/var-tracking.c 2017-07-13 09:18:32.530352523 +0100 @@ -1008,6 +1008,7 @@ adjust_mems (rtx loc, const_rtx old_rtx, rtx mem, addr = loc, tem; machine_mode mem_mode_save; bool store_save; + scalar_int_mode tem_mode, tem_subreg_mode; switch (GET_CODE (loc)) { case REG: @@ -1122,16 +1123,14 @@ adjust_mems (rtx loc, const_rtx old_rtx, || GET_CODE (SUBREG_REG (tem)) == MINUS || GET_CODE (SUBREG_REG (tem)) == MULT || GET_CODE (SUBREG_REG (tem)) == ASHIFT) - && (GET_MODE_CLASS (GET_MODE (tem)) == MODE_INT - || GET_MODE_CLASS (GET_MODE (tem)) == MODE_PARTIAL_INT) - && (GET_MODE_CLASS (GET_MODE (SUBREG_REG (tem))) == MODE_INT - || GET_MODE_CLASS (GET_MODE (SUBREG_REG (tem))) == MODE_PARTIAL_INT) - && GET_MODE_PRECISION (GET_MODE (tem)) - < GET_MODE_PRECISION (GET_MODE (SUBREG_REG (tem))) + && is_a (GET_MODE (tem), &tem_mode) + && is_a (GET_MODE (SUBREG_REG (tem)), + &tem_subreg_mode) + && (GET_MODE_PRECISION (tem_mode) + < GET_MODE_PRECISION (tem_subreg_mode)) && subreg_lowpart_p (tem) && use_narrower_mode_test (SUBREG_REG (tem), tem)) - return use_narrower_mode (SUBREG_REG (tem), GET_MODE (tem), - GET_MODE (SUBREG_REG (tem))); + return use_narrower_mode (SUBREG_REG (tem), tem_mode, tem_subreg_mode); return tem; case ASM_OPERANDS: /* Don't do any replacements in second and following @@ -6301,15 +6300,15 @@ prepare_call_arguments (basic_block bb, else if (REG_P (x)) { cselib_val *val = cselib_lookup (x, GET_MODE (x), 0, VOIDmode); + scalar_int_mode mode; if (val && cselib_preserved_value_p (val)) item = val->val_rtx; - else if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT - || GET_MODE_CLASS (GET_MODE (x)) == MODE_PARTIAL_INT) + else if (is_a (GET_MODE (x), &mode)) { - machine_mode mode; - - FOR_EACH_WIDER_MODE (mode, GET_MODE (x)) + opt_scalar_int_mode mode_iter; + FOR_EACH_WIDER_MODE (mode_iter, mode) { + mode = *mode_iter; if (GET_MODE_BITSIZE (mode) > BITS_PER_WORD) break; Index: gcc/ada/gcc-interface/decl.c =================================================================== --- gcc/ada/gcc-interface/decl.c 2017-07-13 09:18:29.208659553 +0100 +++ gcc/ada/gcc-interface/decl.c 2017-07-13 09:18:32.518353613 +0100 @@ -8801,9 +8801,10 @@ check_ok_for_atomic_type (tree type, Ent /* Consider all aligned floating-point types atomic and any aligned types that are represented by integers no wider than a machine word. */ + scalar_int_mode int_mode; if ((mclass == MODE_FLOAT - || ((mclass == MODE_INT || mclass == MODE_PARTIAL_INT) - && GET_MODE_BITSIZE (mode) <= BITS_PER_WORD)) + || (is_a (mode, &int_mode) + && GET_MODE_BITSIZE (int_mode) <= BITS_PER_WORD)) && align >= GET_MODE_ALIGNMENT (mode)) return; Index: gcc/ada/gcc-interface/trans.c =================================================================== --- gcc/ada/gcc-interface/trans.c 2017-06-30 12:50:38.300660048 +0100 +++ gcc/ada/gcc-interface/trans.c 2017-07-13 09:18:32.519353522 +0100 @@ -1275,6 +1275,7 @@ Pragma_to_gnu (Node_Id gnat_node) tree gnu_expr = gnat_to_gnu (gnat_expr); int use_address; machine_mode mode; + scalar_int_mode int_mode; tree asm_constraint = NULL_TREE; #ifdef ASM_COMMENT_START char *comment; @@ -1286,9 +1287,8 @@ Pragma_to_gnu (Node_Id gnat_node) /* Use the value only if it fits into a normal register, otherwise use the address. */ mode = TYPE_MODE (TREE_TYPE (gnu_expr)); - use_address = ((GET_MODE_CLASS (mode) != MODE_INT - && GET_MODE_CLASS (mode) != MODE_PARTIAL_INT) - || GET_MODE_SIZE (mode) > UNITS_PER_WORD); + use_address = (!is_a (mode, &int_mode) + || GET_MODE_SIZE (int_mode) > UNITS_PER_WORD); if (use_address) gnu_expr = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_expr); Index: gcc/ada/gcc-interface/utils.c =================================================================== --- gcc/ada/gcc-interface/utils.c 2017-07-13 09:18:29.208659553 +0100 +++ gcc/ada/gcc-interface/utils.c 2017-07-13 09:18:32.519353522 +0100 @@ -3470,8 +3470,9 @@ gnat_type_for_mode (machine_mode mode, i return float_type_for_precision (GET_MODE_PRECISION (float_mode), float_mode); - if (SCALAR_INT_MODE_P (mode)) - return gnat_type_for_size (GET_MODE_BITSIZE (mode), unsignedp); + scalar_int_mode int_mode; + if (is_a (mode, &int_mode)) + return gnat_type_for_size (GET_MODE_BITSIZE (int_mode), unsignedp); if (VECTOR_MODE_P (mode)) { Index: gcc/fortran/trans-types.c =================================================================== --- gcc/fortran/trans-types.c 2017-07-13 09:18:26.363931259 +0100 +++ gcc/fortran/trans-types.c 2017-07-13 09:18:32.525352977 +0100 @@ -3109,14 +3109,15 @@ gfc_type_for_mode (machine_mode mode, in { int i; tree *base; + scalar_int_mode int_mode; if (GET_MODE_CLASS (mode) == MODE_FLOAT) base = gfc_real_types; else if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT) base = gfc_complex_types; - else if (SCALAR_INT_MODE_P (mode)) + else if (is_a (mode, &int_mode)) { - tree type = gfc_type_for_size (GET_MODE_PRECISION (mode), unsignedp); + tree type = gfc_type_for_size (GET_MODE_PRECISION (int_mode), unsignedp); return type != NULL_TREE && mode == TYPE_MODE (type) ? type : NULL_TREE; } else if (VECTOR_MODE_P (mode))