From patchwork Thu Jul 13 08:53:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107627 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1935726qge; Thu, 13 Jul 2017 01:54:27 -0700 (PDT) X-Received: by 10.98.147.69 with SMTP id b66mr38119045pfe.148.1499936067817; Thu, 13 Jul 2017 01:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936067; cv=none; d=google.com; s=arc-20160816; b=fxNa9QneigE+QGbujxU0yn9DRMCImnbg3SaS8JFfDJwW5TOOmY8cpxRdEkXTUtQfG8 xnNeNdzaM8WbgG8znCheIRQIE3/HYpaANLs7PZBe0SZYkGh1QDaexlmysMRKjUZXoIX5 1Vu1Q0fxG/kttcecd1qt9ZQeIC2JxRSlj/fG/s01OtrRrmj6Iwy+pe0cKEtuTbWOwLw5 VTVDk+ipcrA0+0sOCQGvZHyYV0sMKxQI0jsMjzbQKhh8Z1Q0IlPNJugc+Ssncc5WSj2b KEPxJ6xnKhFwKSigF29h3fPcq63PAbCRXOrCHD8y413XfIq+KS5Gudx40+xrhmNMlFB/ trUA== 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=AxxiR52/YTsBP24eyOk1LARQGEd1EGXWVQL5PwekURY=; b=Fc3uYgxIPQxZ7GJAh+dezBiX5TxM5hi9f+I4LXqPJkLu7equ9Wsry1+TGOXZ8sWYA+ Sp537RY7QfqoFs0ww74VABg1lqTW/SJ7wFaRiLyzdT9ruOpdnc5ZOLqP7hCoZ9NUSHYn X0SHzmTEs5mC16mV/oayx/cw9zP2fzFCm6R8EH6nRiSWmiMAdh2E0eHQntfcrhMkxg6+ vHklDhCBj9J0uWhrn8SHIf5a14bzomcP5H5IeC9e+nzkCtl2lpYHzNOGG2MT28FE+NiY t8no4kIfsJ/uAizbVLVHOfD7VO+1hmO/xvpj3FhPknllc4+mTgpLg63ighwvuWHAahS2 ok0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=xNE2EnhS; spf=pass (google.com: domain of gcc-patches-return-458032-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458032-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 o33si3998112plb.384.2017.07.13.01.54.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:54:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458032-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=xNE2EnhS; spf=pass (google.com: domain of gcc-patches-return-458032-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458032-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=Z0EIuRqkeOYYD2/x5LPI2rbbHPc5N MiVLF+Gkc5nEZI7EkOMs3uoUgfk9x2jIZ1YRJny0pSczVFS9eJN7+F7Dq5SeuRS1 QkjOmcdvtb6jbc78xvh4uwAUmoYG96aUgWY7a5QCs0pVnndCvL5FWlKy8mzH/0PE mfbMpKIdpbUfgk= 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=6j0fvPZy+RGBXE/+xYIxVDoPkms=; b=xNE 2EnhShqA8ZXioR7LIrWI5jmVYZsCRgUxTWSkamIoDCUNXvqK7pBiPVG7tx6+0rXo hDeYIZt+ioUGkVOIZQAjw8rLgyEr0kTLQ8gXFnUzKOaHV4cE5R97PoqegYAjUDC9 veb4D315AD9Ln/vWdybEa6NBkad73O4GsrzoL4q8= Received: (qmail 106073 invoked by alias); 13 Jul 2017 08:53:21 -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 105381 invoked by uid 89); 13 Jul 2017 08:53:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:53:13 +0000 Received: by mail-wm0-f48.google.com with SMTP id f67so18326979wmh.1 for ; Thu, 13 Jul 2017 01:53:12 -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=AxxiR52/YTsBP24eyOk1LARQGEd1EGXWVQL5PwekURY=; b=CN/PwVkP4batsLD7pQXwb4/F7KOU0STh9paTRz22k4X+UF/HTWa6DME9gklqU1VVXL Mfl/XwYBmLX5nNy39hvUwit+7d4ekrLXEaqGI7B3eifSqTNUmSDlEtU9oOn7/LZL3vqd MQ6AQONMdL83czkj3byVu3ce7+TAU7dqdraFnw6DHr9BGpBEG5O/p4xr/0TcDFifkfLo ckEJVeWpxOl/qyo4fA+rz5My9p5L19yyL0JfTrW3YcGdx2krTprvs+ZAPqQRTBmdStPD ztl5LMigjXOZJ087n6+64vCfi5B5dqsBy9KBKKnvxPgnU/Csd9hdP9N5m2r4LHHAS6pY kGgA== X-Gm-Message-State: AIVw111vbr8rTJPgPGdJsxoU6QEpaKtL0farqXA9rFp3nHTa25PQjfuM 0+jsmXPu6hs/e42YPOifGQ== X-Received: by 10.28.47.67 with SMTP id v64mr1137582wmv.84.1499935990656; Thu, 13 Jul 2017 01:53:10 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 21sm6149459wmo.16.2017.07.13.01.53.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:53:09 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [41/77] Split scalar integer handling out of force_to_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:53:08 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <878tjshg5n.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 force_to_mode exits partway through for modes that aren't scalar integers. This patch splits the remainder of the function out into a subroutine, force_int_to_mode, so that the modes from that point on can have type scalar_int_mode. The patch also makes sure that xmode is kept up-to-date with x and uses xmode instead of GET_MODE (x) throughout. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (force_int_to_mode): New function, split out from... (force_to_mode): ...here. Keep xmode up-to-date and use it instead of GET_MODE (x). Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:42.160519154 +0100 +++ gcc/combine.c 2017-07-13 09:18:42.622481204 +0100 @@ -449,6 +449,8 @@ static rtx extract_left_shift (rtx, int) static int get_pos_from_mask (unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT *); static rtx canon_reg_for_combine (rtx, rtx); +static rtx force_int_to_mode (rtx, scalar_int_mode, scalar_int_mode, + scalar_int_mode, unsigned HOST_WIDE_INT, int); static rtx force_to_mode (rtx, machine_mode, unsigned HOST_WIDE_INT, int); static rtx if_then_else_cond (rtx, rtx *, rtx *); @@ -8517,8 +8519,7 @@ force_to_mode (rtx x, machine_mode mode, enum rtx_code code = GET_CODE (x); int next_select = just_select || code == XOR || code == NOT || code == NEG; machine_mode op_mode; - unsigned HOST_WIDE_INT fuller_mask, nonzero; - rtx op0, op1, temp; + unsigned HOST_WIDE_INT nonzero; /* If this is a CALL or ASM_OPERANDS, don't do anything. Some of the code below will do the wrong thing since the mode of such an @@ -8546,15 +8547,6 @@ force_to_mode (rtx x, machine_mode mode, if (op_mode) mask &= GET_MODE_MASK (op_mode); - /* When we have an arithmetic operation, or a shift whose count we - do not know, we need to assume that all bits up to the highest-order - bit in MASK will be needed. This is how we form such a mask. */ - if (mask & (HOST_WIDE_INT_1U << (HOST_BITS_PER_WIDE_INT - 1))) - fuller_mask = HOST_WIDE_INT_M1U; - else - fuller_mask = ((HOST_WIDE_INT_1U << (floor_log2 (mask) + 1)) - - 1); - /* Determine what bits of X are guaranteed to be (non)zero. */ nonzero = nonzero_bits (x, mode); @@ -8592,9 +8584,42 @@ force_to_mode (rtx x, machine_mode mode, & ~GET_MODE_MASK (GET_MODE (SUBREG_REG (x))))))) return force_to_mode (SUBREG_REG (x), mode, mask, next_select); - /* The arithmetic simplifications here only work for scalar integer modes. */ - if (!SCALAR_INT_MODE_P (mode) || !SCALAR_INT_MODE_P (GET_MODE (x))) - return gen_lowpart_or_truncate (mode, x); + scalar_int_mode int_mode, xmode; + if (is_a (mode, &int_mode) + && is_a (GET_MODE (x), &xmode)) + /* OP_MODE is either MODE or XMODE, so it must be a scalar + integer too. */ + return force_int_to_mode (x, int_mode, xmode, + as_a (op_mode), + mask, just_select); + + return gen_lowpart_or_truncate (mode, x); +} + +/* Subroutine of force_to_mode that handles cases in which both X and + the result are scalar integers. MODE is the mode of the result, + XMODE is the mode of X, and OP_MODE says which of MODE or XMODE + is preferred for simplified versions of X. The other arguments + are as for force_to_mode. */ + +static rtx +force_int_to_mode (rtx x, scalar_int_mode mode, scalar_int_mode xmode, + scalar_int_mode op_mode, unsigned HOST_WIDE_INT mask, + int just_select) +{ + enum rtx_code code = GET_CODE (x); + int next_select = just_select || code == XOR || code == NOT || code == NEG; + unsigned HOST_WIDE_INT fuller_mask; + rtx op0, op1, temp; + + /* When we have an arithmetic operation, or a shift whose count we + do not know, we need to assume that all bits up to the highest-order + bit in MASK will be needed. This is how we form such a mask. */ + if (mask & (HOST_WIDE_INT_1U << (HOST_BITS_PER_WIDE_INT - 1))) + fuller_mask = HOST_WIDE_INT_M1U; + else + fuller_mask = ((HOST_WIDE_INT_1U << (floor_log2 (mask) + 1)) + - 1); switch (code) { @@ -8625,14 +8650,14 @@ force_to_mode (rtx x, machine_mode mode, { x = simplify_and_const_int (x, op_mode, XEXP (x, 0), mask & INTVAL (XEXP (x, 1))); + xmode = op_mode; /* If X is still an AND, see if it is an AND with a mask that is just some low-order bits. If so, and it is MASK, we don't need it. */ if (GET_CODE (x) == AND && CONST_INT_P (XEXP (x, 1)) - && ((INTVAL (XEXP (x, 1)) & GET_MODE_MASK (GET_MODE (x))) - == mask)) + && (INTVAL (XEXP (x, 1)) & GET_MODE_MASK (xmode)) == mask) x = XEXP (x, 0); /* If it remains an AND, try making another AND with the bits @@ -8641,18 +8666,17 @@ force_to_mode (rtx x, machine_mode mode, cheaper constant. */ if (GET_CODE (x) == AND && CONST_INT_P (XEXP (x, 1)) - && GET_MODE_MASK (GET_MODE (x)) != mask - && HWI_COMPUTABLE_MODE_P (GET_MODE (x))) + && GET_MODE_MASK (xmode) != mask + && HWI_COMPUTABLE_MODE_P (xmode)) { unsigned HOST_WIDE_INT cval - = UINTVAL (XEXP (x, 1)) - | (GET_MODE_MASK (GET_MODE (x)) & ~mask); + = UINTVAL (XEXP (x, 1)) | (GET_MODE_MASK (xmode) & ~mask); rtx y; - y = simplify_gen_binary (AND, GET_MODE (x), XEXP (x, 0), - gen_int_mode (cval, GET_MODE (x))); - if (set_src_cost (y, GET_MODE (x), optimize_this_for_speed_p) - < set_src_cost (x, GET_MODE (x), optimize_this_for_speed_p)) + y = simplify_gen_binary (AND, xmode, XEXP (x, 0), + gen_int_mode (cval, xmode)); + if (set_src_cost (y, xmode, optimize_this_for_speed_p) + < set_src_cost (x, xmode, optimize_this_for_speed_p)) x = y; } @@ -8682,7 +8706,7 @@ force_to_mode (rtx x, machine_mode mode, && pow2p_hwi (- smask) && (nonzero_bits (XEXP (x, 0), mode) & ~smask) == 0 && (INTVAL (XEXP (x, 1)) & ~smask) != 0) - return force_to_mode (plus_constant (GET_MODE (x), XEXP (x, 0), + return force_to_mode (plus_constant (xmode, XEXP (x, 0), (INTVAL (XEXP (x, 1)) & smask)), mode, smask, next_select); } @@ -8713,8 +8737,7 @@ force_to_mode (rtx x, machine_mode mode, if (CONST_INT_P (XEXP (x, 0)) && least_bit_hwi (UINTVAL (XEXP (x, 0))) > mask) { - x = simplify_gen_unary (NEG, GET_MODE (x), XEXP (x, 1), - GET_MODE (x)); + x = simplify_gen_unary (NEG, xmode, XEXP (x, 1), xmode); return force_to_mode (x, mode, mask, next_select); } @@ -8723,8 +8746,7 @@ force_to_mode (rtx x, machine_mode mode, if (CONST_INT_P (XEXP (x, 0)) && ((UINTVAL (XEXP (x, 0)) | fuller_mask) == UINTVAL (XEXP (x, 0)))) { - x = simplify_gen_unary (NOT, GET_MODE (x), - XEXP (x, 1), GET_MODE (x)); + x = simplify_gen_unary (NOT, xmode, XEXP (x, 1), xmode); return force_to_mode (x, mode, mask, next_select); } @@ -8745,16 +8767,16 @@ force_to_mode (rtx x, machine_mode mode, && CONST_INT_P (XEXP (x, 1)) && ((INTVAL (XEXP (XEXP (x, 0), 1)) + floor_log2 (INTVAL (XEXP (x, 1)))) - < GET_MODE_PRECISION (GET_MODE (x))) + < GET_MODE_PRECISION (xmode)) && (UINTVAL (XEXP (x, 1)) - & ~nonzero_bits (XEXP (x, 0), GET_MODE (x))) == 0) + & ~nonzero_bits (XEXP (x, 0), xmode)) == 0) { temp = gen_int_mode ((INTVAL (XEXP (x, 1)) & mask) << INTVAL (XEXP (XEXP (x, 0), 1)), - GET_MODE (x)); - temp = simplify_gen_binary (GET_CODE (x), GET_MODE (x), + xmode); + temp = simplify_gen_binary (GET_CODE (x), xmode, XEXP (XEXP (x, 0), 0), temp); - x = simplify_gen_binary (LSHIFTRT, GET_MODE (x), temp, + x = simplify_gen_binary (LSHIFTRT, xmode, temp, XEXP (XEXP (x, 0), 1)); return force_to_mode (x, mode, mask, next_select); } @@ -8778,8 +8800,11 @@ force_to_mode (rtx x, machine_mode mode, op0 = gen_lowpart_or_truncate (op_mode, op0); op1 = gen_lowpart_or_truncate (op_mode, op1); - if (op_mode != GET_MODE (x) || op0 != XEXP (x, 0) || op1 != XEXP (x, 1)) - x = simplify_gen_binary (code, op_mode, op0, op1); + if (op_mode != xmode || op0 != XEXP (x, 0) || op1 != XEXP (x, 1)) + { + x = simplify_gen_binary (code, op_mode, op0, op1); + xmode = op_mode; + } break; case ASHIFT: @@ -8812,8 +8837,11 @@ force_to_mode (rtx x, machine_mode mode, force_to_mode (XEXP (x, 0), op_mode, mask, next_select)); - if (op_mode != GET_MODE (x) || op0 != XEXP (x, 0)) - x = simplify_gen_binary (code, op_mode, op0, XEXP (x, 1)); + if (op_mode != xmode || op0 != XEXP (x, 0)) + { + x = simplify_gen_binary (code, op_mode, op0, XEXP (x, 1)); + xmode = op_mode; + } break; case LSHIFTRT: @@ -8835,13 +8863,16 @@ force_to_mode (rtx x, machine_mode mode, /* We can only change the mode of the shift if we can do arithmetic in the mode of the shift and INNER_MASK is no wider than the width of X's mode. */ - if ((inner_mask & ~GET_MODE_MASK (GET_MODE (x))) != 0) - op_mode = GET_MODE (x); + if ((inner_mask & ~GET_MODE_MASK (xmode)) != 0) + op_mode = xmode; inner = force_to_mode (inner, op_mode, inner_mask, next_select); - if (GET_MODE (x) != op_mode || inner != XEXP (x, 0)) - x = simplify_gen_binary (LSHIFTRT, op_mode, inner, XEXP (x, 1)); + if (xmode != op_mode || inner != XEXP (x, 0)) + { + x = simplify_gen_binary (LSHIFTRT, op_mode, inner, XEXP (x, 1)); + xmode = op_mode; + } } /* If we have (and (lshiftrt FOO C1) C2) where the combination of the @@ -8854,17 +8885,17 @@ force_to_mode (rtx x, machine_mode mode, bit. */ && ((INTVAL (XEXP (x, 1)) + num_sign_bit_copies (XEXP (x, 0), GET_MODE (XEXP (x, 0)))) - >= GET_MODE_PRECISION (GET_MODE (x))) + >= GET_MODE_PRECISION (xmode)) && pow2p_hwi (mask + 1) /* Number of bits left after the shift must be more than the mask needs. */ && ((INTVAL (XEXP (x, 1)) + exact_log2 (mask + 1)) - <= GET_MODE_PRECISION (GET_MODE (x))) + <= GET_MODE_PRECISION (xmode)) /* Must be more sign bit copies than the mask needs. */ && ((int) num_sign_bit_copies (XEXP (x, 0), GET_MODE (XEXP (x, 0))) >= exact_log2 (mask + 1))) - x = simplify_gen_binary (LSHIFTRT, GET_MODE (x), XEXP (x, 0), - GEN_INT (GET_MODE_PRECISION (GET_MODE (x)) + x = simplify_gen_binary (LSHIFTRT, xmode, XEXP (x, 0), + GEN_INT (GET_MODE_PRECISION (xmode) - exact_log2 (mask + 1))); goto shiftrt; @@ -8872,7 +8903,7 @@ force_to_mode (rtx x, machine_mode mode, case ASHIFTRT: /* If we are just looking for the sign bit, we don't need this shift at all, even if it has a variable count. */ - if (val_signbit_p (GET_MODE (x), mask)) + if (val_signbit_p (xmode, mask)) return force_to_mode (XEXP (x, 0), mode, mask, next_select); /* If this is a shift by a constant, get a mask that contains those bits @@ -8885,13 +8916,14 @@ force_to_mode (rtx x, machine_mode mode, if (CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) >= 0 && INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT) { + unsigned HOST_WIDE_INT nonzero; int i; /* If the considered data is wider than HOST_WIDE_INT, we can't represent a mask for all its bits in a single scalar. But we only care about the lower bits, so calculate these. */ - if (GET_MODE_PRECISION (GET_MODE (x)) > HOST_BITS_PER_WIDE_INT) + if (GET_MODE_PRECISION (xmode) > HOST_BITS_PER_WIDE_INT) { nonzero = HOST_WIDE_INT_M1U; @@ -8900,21 +8932,21 @@ force_to_mode (rtx x, machine_mode mode, We need only shift if these are fewer than nonzero can hold. If not, we must keep all bits set in nonzero. */ - if (GET_MODE_PRECISION (GET_MODE (x)) - INTVAL (XEXP (x, 1)) + if (GET_MODE_PRECISION (xmode) - INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT) nonzero >>= INTVAL (XEXP (x, 1)) + HOST_BITS_PER_WIDE_INT - - GET_MODE_PRECISION (GET_MODE (x)) ; + - GET_MODE_PRECISION (xmode); } else { - nonzero = GET_MODE_MASK (GET_MODE (x)); + nonzero = GET_MODE_MASK (xmode); nonzero >>= INTVAL (XEXP (x, 1)); } if ((mask & ~nonzero) == 0) { - x = simplify_shift_const (NULL_RTX, LSHIFTRT, GET_MODE (x), + x = simplify_shift_const (NULL_RTX, LSHIFTRT, xmode, XEXP (x, 0), INTVAL (XEXP (x, 1))); if (GET_CODE (x) != ASHIFTRT) return force_to_mode (x, mode, mask, next_select); @@ -8923,8 +8955,8 @@ force_to_mode (rtx x, machine_mode mode, else if ((i = exact_log2 (mask)) >= 0) { x = simplify_shift_const - (NULL_RTX, LSHIFTRT, GET_MODE (x), XEXP (x, 0), - GET_MODE_PRECISION (GET_MODE (x)) - 1 - i); + (NULL_RTX, LSHIFTRT, xmode, XEXP (x, 0), + GET_MODE_PRECISION (xmode) - 1 - i); if (GET_CODE (x) != ASHIFTRT) return force_to_mode (x, mode, mask, next_select); @@ -8934,8 +8966,7 @@ force_to_mode (rtx x, machine_mode mode, /* If MASK is 1, convert this to an LSHIFTRT. This can be done even if the shift count isn't a constant. */ if (mask == 1) - x = simplify_gen_binary (LSHIFTRT, GET_MODE (x), - XEXP (x, 0), XEXP (x, 1)); + x = simplify_gen_binary (LSHIFTRT, xmode, XEXP (x, 0), XEXP (x, 1)); shiftrt: @@ -8947,7 +8978,7 @@ force_to_mode (rtx x, machine_mode mode, && CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) >= 0 && (INTVAL (XEXP (x, 1)) - <= GET_MODE_PRECISION (GET_MODE (x)) - (floor_log2 (mask) + 1)) + <= GET_MODE_PRECISION (xmode) - (floor_log2 (mask) + 1)) && GET_CODE (XEXP (x, 0)) == ASHIFT && XEXP (XEXP (x, 0), 1) == XEXP (x, 1)) return force_to_mode (XEXP (XEXP (x, 0), 0), mode, mask, @@ -8965,12 +8996,11 @@ force_to_mode (rtx x, machine_mode mode, && INTVAL (XEXP (x, 1)) >= 0) { temp = simplify_binary_operation (code == ROTATE ? ROTATERT : ROTATE, - GET_MODE (x), - gen_int_mode (mask, GET_MODE (x)), + xmode, gen_int_mode (mask, xmode), XEXP (x, 1)); if (temp && CONST_INT_P (temp)) - x = simplify_gen_binary (code, GET_MODE (x), - force_to_mode (XEXP (x, 0), GET_MODE (x), + x = simplify_gen_binary (code, xmode, + force_to_mode (XEXP (x, 0), xmode, INTVAL (temp), next_select), XEXP (x, 1)); } @@ -8997,14 +9027,12 @@ force_to_mode (rtx x, machine_mode mode, && CONST_INT_P (XEXP (XEXP (x, 0), 1)) && INTVAL (XEXP (XEXP (x, 0), 1)) >= 0 && (INTVAL (XEXP (XEXP (x, 0), 1)) + floor_log2 (mask) - < GET_MODE_PRECISION (GET_MODE (x))) + < GET_MODE_PRECISION (xmode)) && INTVAL (XEXP (XEXP (x, 0), 1)) < HOST_BITS_PER_WIDE_INT) { - temp = gen_int_mode (mask << INTVAL (XEXP (XEXP (x, 0), 1)), - GET_MODE (x)); - temp = simplify_gen_binary (XOR, GET_MODE (x), - XEXP (XEXP (x, 0), 0), temp); - x = simplify_gen_binary (LSHIFTRT, GET_MODE (x), + temp = gen_int_mode (mask << INTVAL (XEXP (XEXP (x, 0), 1)), xmode); + temp = simplify_gen_binary (XOR, xmode, XEXP (XEXP (x, 0), 0), temp); + x = simplify_gen_binary (LSHIFTRT, xmode, temp, XEXP (XEXP (x, 0), 1)); return force_to_mode (x, mode, mask, next_select); @@ -9018,8 +9046,11 @@ force_to_mode (rtx x, machine_mode mode, op0 = gen_lowpart_or_truncate (op_mode, force_to_mode (XEXP (x, 0), mode, mask, next_select)); - if (op_mode != GET_MODE (x) || op0 != XEXP (x, 0)) - x = simplify_gen_unary (code, op_mode, op0, op_mode); + if (op_mode != xmode || op0 != XEXP (x, 0)) + { + x = simplify_gen_unary (code, op_mode, op0, op_mode); + xmode = op_mode; + } break; case NE: @@ -9040,14 +9071,14 @@ force_to_mode (rtx x, machine_mode mode, /* We have no way of knowing if the IF_THEN_ELSE can itself be written in a narrower mode. We play it safe and do not do so. */ - op0 = gen_lowpart_or_truncate (GET_MODE (x), + op0 = gen_lowpart_or_truncate (xmode, force_to_mode (XEXP (x, 1), mode, mask, next_select)); - op1 = gen_lowpart_or_truncate (GET_MODE (x), + op1 = gen_lowpart_or_truncate (xmode, force_to_mode (XEXP (x, 2), mode, mask, next_select)); if (op0 != XEXP (x, 1) || op1 != XEXP (x, 2)) - x = simplify_gen_ternary (IF_THEN_ELSE, GET_MODE (x), + x = simplify_gen_ternary (IF_THEN_ELSE, xmode, GET_MODE (XEXP (x, 0)), XEXP (x, 0), op0, op1); break;