From patchwork Thu Jul 13 08:56:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107636 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1938351qge; Thu, 13 Jul 2017 01:58:05 -0700 (PDT) X-Received: by 10.98.30.194 with SMTP id e185mr28769407pfe.158.1499936284540; Thu, 13 Jul 2017 01:58:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936284; cv=none; d=google.com; s=arc-20160816; b=ZC2WtYFFxv03YkDH/nhp7Jshu1/TGdaC1sHl7JVeIE9Hp99y8dIjuBSPyLxsJ7KUpa Qh8Z7PsclM/NfhduiRD8SC8nT0rhIjkEkOfhJGwpzZTRgnLs89PWh0xYwLqQ2LFHdIfw hGQ+tpH05S6Iw12/QAAIv0bLPfjgDPiob6tcr5mhpNitArtPkpudY4nwxIH83qO13Soq hFpoGXO/R7MCzCCu/x3xlBOhhFR7xHjYCu7IQ8QGAC3NKEZsd2PfVDjeXezFBzfnCtpF 42Kp3mwJelwaZJeRNUEK8FSf9NB7S/U1b5sypcJRP9Nakc3MlF4HGeEAV21FM3dkYU24 Wvug== 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=PtxwxGU3OHhpdiFgKdF9HTrJsBaH9dEIliw4BmYKHHY=; b=bNAEVM3LT9HEKmvilaOKxdma4ecGItc4y6pFOA3ke+XIoRWv3U73eyfOPx55OjtU4+ kS9Stcm8ZJmeQVkPXjbcRLl5D7kY0sGKJlBJr/0TqnnSRAYwIv2W03Gp43fEFZgUWA/Z S8B+P8wY4jwllVS5EbKTfXj84VVEdDmwV26s4nw37SRV7iBWfBja0aC4GBTI/AbelOcd nE49/LtidSn7FSDzTRtaex/oXYDv+C+f5QsKUR76/1lcDpEvDO441ZDhbu9T5Qmp9Xvz Av2MSxJ3h28KTAtpRp9SXPvULjUGxlOXWoFNl3I7i4C1+mCijOY1UZcc96JFZ7UhpNzL SX9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=LwNdmFQQ; spf=pass (google.com: domain of gcc-patches-return-458041-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458041-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 l21si3769480pfj.297.2017.07.13.01.58.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:58:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458041-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=LwNdmFQQ; spf=pass (google.com: domain of gcc-patches-return-458041-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458041-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=EsPvhj+aaWSdpLX8wskIuTsXR2PyQ pYG0ybB1A0An6V3X8F/Xmx4v27E0Vzu0ui4rNlHF/60ArMR4XBchwUkFI27VLoDg UJBM0SRGPMqc8trlXfO20swmQ6NZq8C6q+tRGhi5cFnl1BJT6KtJCinKBxe7qKc9 lTi3fZxT/5Hg9w= 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=no0UDiEfaZlSp9RcQkATolupD0s=; b=LwN dmFQQ6NV5pSjykm+uEf0jdyF/7vTsYlrtsuCLvtvyQfwJHZfGaUEuXUKwQFWlE1w W7sNNjoPN//p/+8EfZIkeKwe6PcL4ywCdr0m7fAouN8XpalHub1Sz8o4rCyEkfTS ZTHMBNjGz9rI4rYU30dCpeXNpEPEU6RoONzBJVK4= Received: (qmail 14425 invoked by alias); 13 Jul 2017 08:56:17 -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 13753 invoked by uid 89); 13 Jul 2017 08:56:16 -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= X-HELO: mail-wr0-f180.google.com Received: from mail-wr0-f180.google.com (HELO mail-wr0-f180.google.com) (209.85.128.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:56:13 +0000 Received: by mail-wr0-f180.google.com with SMTP id c11so49489961wrc.3 for ; Thu, 13 Jul 2017 01:56: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=PtxwxGU3OHhpdiFgKdF9HTrJsBaH9dEIliw4BmYKHHY=; b=sYsC4FPgOugHTMf30IEiCQjV+JMeKocRYVGBjUD5nFDUtsWz5GTEQMV+eH8SaukFmS gs9q/EjznIHOd2VWlXlnQjw4G+P/uKvTSrQBOf30noheijCnbuzFxe+eGI/5xvMRX/dc B8EVDY+vIrQYyMh3VxEzDxZ4/AIaaIWNEmhS6A5QztAc/um0tLve60HKxCyTGNfRlssH acr4o6yNnwQTZa7SOeEQb6S7DRSn/2vddyB4FhJ1aJOXJY/qsxHu87AZzDxlapbRzbPh HJ0xmDdf9O45peoCWDQRFM8Kum/8HfPMtZozFRClOcCxR/sVBlZMB/BdBc16y5GbZj1I CpHA== X-Gm-Message-State: AIVw110MlABkN+UUAoPD4PNNeOP+Rc5YoZ897yTbFVGbcDchpX46Pt4a iKkjcp8wQbtlGSS2lRPs6g== X-Received: by 10.223.175.229 with SMTP id y37mr1040000wrd.61.1499936170139; Thu, 13 Jul 2017 01:56:10 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id y35sm4712452wrc.51.2017.07.13.01.56.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:56: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: [50/77] Add helper routines for SUBREG_PROMOTED_VAR_P subregs References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:56:07 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <8760ewg1g8.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 When subregs contain promoted values, as indicated by SUBREG_PROMOTED_VAR_P, both the unpromoted (outer) and promoted (inner) values are known to be scalar integers. This patch adds helper routines that get the modes as scalar_int_modes. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * rtl.h (subreg_unpromoted_mode, subreg_promoted_mode): New functions. * expr.c (convert_move): Use them. (convert_modes): Likewise. (store_expr_with_bounds): Likewise. Index: gcc/rtl.h =================================================================== --- gcc/rtl.h 2017-07-13 09:18:45.761227536 +0100 +++ gcc/rtl.h 2017-07-13 09:18:46.226190608 +0100 @@ -2766,6 +2766,24 @@ unwrap_const_vec_duplicate (T x) return x; } +/* Return the unpromoted (outer) mode of SUBREG_PROMOTED_VAR_P subreg X. */ + +inline scalar_int_mode +subreg_unpromoted_mode (rtx x) +{ + gcc_checking_assert (SUBREG_PROMOTED_VAR_P (x)); + return as_a (GET_MODE (x)); +} + +/* Return the promoted (inner) mode of SUBREG_PROMOTED_VAR_P subreg X. */ + +inline scalar_int_mode +subreg_promoted_mode (rtx x) +{ + gcc_checking_assert (SUBREG_PROMOTED_VAR_P (x)); + return as_a (GET_MODE (SUBREG_REG (x))); +} + /* In emit-rtl.c */ extern rtvec gen_rtvec_v (int, rtx *); extern rtvec gen_rtvec_v (int, rtx_insn **); Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:44.578322246 +0100 +++ gcc/expr.c 2017-07-13 09:18:46.226190608 +0100 @@ -243,7 +243,7 @@ convert_move (rtx to, rtx from, int unsi if (GET_CODE (from) == SUBREG && SUBREG_PROMOTED_VAR_P (from) && is_a (to_mode, &to_int_mode) - && (GET_MODE_PRECISION (GET_MODE (SUBREG_REG (from))) + && (GET_MODE_PRECISION (subreg_promoted_mode (from)) >= GET_MODE_PRECISION (to_int_mode)) && SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp)) from = gen_lowpart (to_int_mode, from), from_mode = to_int_mode; @@ -641,7 +641,8 @@ convert_modes (machine_mode mode, machin if (GET_CODE (x) == SUBREG && SUBREG_PROMOTED_VAR_P (x) && is_a (mode, &int_mode) - && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (int_mode) + && (GET_MODE_PRECISION (subreg_promoted_mode (x)) + >= GET_MODE_PRECISION (int_mode)) && SUBREG_CHECK_PROMOTED_SIGN (x, unsignedp)) x = gen_lowpart (int_mode, SUBREG_REG (x)); @@ -5422,6 +5423,8 @@ store_expr_with_bounds (tree exp, rtx ta expression. */ { rtx inner_target = 0; + scalar_int_mode outer_mode = subreg_unpromoted_mode (target); + scalar_int_mode inner_mode = subreg_promoted_mode (target); /* We can do the conversion inside EXP, which will often result in some optimizations. Do the conversion in two steps: first @@ -5431,7 +5434,7 @@ store_expr_with_bounds (tree exp, rtx ta converting modes. */ if (INTEGRAL_TYPE_P (TREE_TYPE (exp)) && TREE_TYPE (TREE_TYPE (exp)) == 0 - && GET_MODE_PRECISION (GET_MODE (target)) + && GET_MODE_PRECISION (outer_mode) == TYPE_PRECISION (TREE_TYPE (exp))) { if (!SUBREG_CHECK_PROMOTED_SIGN (target, @@ -5451,8 +5454,7 @@ store_expr_with_bounds (tree exp, rtx ta } exp = fold_convert_loc (loc, lang_hooks.types.type_for_mode - (GET_MODE (SUBREG_REG (target)), - SUBREG_PROMOTED_SIGN (target)), + (inner_mode, SUBREG_PROMOTED_SIGN (target)), exp); inner_target = SUBREG_REG (target); @@ -5478,10 +5480,9 @@ store_expr_with_bounds (tree exp, rtx ta sure that we properly convert it. */ if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode) { - temp = convert_modes (GET_MODE (target), TYPE_MODE (TREE_TYPE (exp)), + temp = convert_modes (outer_mode, TYPE_MODE (TREE_TYPE (exp)), temp, SUBREG_PROMOTED_SIGN (target)); - temp = convert_modes (GET_MODE (SUBREG_REG (target)), - GET_MODE (target), temp, + temp = convert_modes (inner_mode, outer_mode, temp, SUBREG_PROMOTED_SIGN (target)); }