From patchwork Thu Aug 24 18:21:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 110946 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp6062676qge; Thu, 24 Aug 2017 11:21:59 -0700 (PDT) X-Received: by 10.99.120.205 with SMTP id t196mr7087187pgc.35.1503598919865; Thu, 24 Aug 2017 11:21:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503598919; cv=none; d=google.com; s=arc-20160816; b=dUpypleHbO6HOaxmPrhzGSDgz5d8Onub/ENm7mnjB0ap/0SniXO762wmVUXORlAEtL 2BhlxkfQLICneS1hZPl87F9JIuEN3jp/E37ARj88l7xMlzv1k1ng8KmLHGbLDR1TmraV uWdgaow3Rug+E08YsWjxCAo+d479yO5iHunRkjW0mlHKWc2kQLNDwqtpaXQ26At4HOZ5 fl2pw9Q+FyoxPfs0uEMYDGveEkGF7SlGHa5TpE/XBiicVpk61tfrO80wN0q5XrNhaYDi gJ/E3JGYs0bR4lVcR4ouSbW5NLLHNhejqB0QqDULp3EQgy2FxpKnWQaSSEL35bTC0z9L PRFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date: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=UVoYnMFI7Y7+iulWbctMPmrUh3TQg76doGqMoOuYjLQ=; b=RtUtZWjz4TfR62cES9B1ix9oGjDk0Rh6PIaXMIa1HPWy/a9/oVHZQOCTrcOV9ZvDfe UWhg1M1LyKEAO7xh1FGQRsg0oql6X5X6KRp0Mrw6pYx/NttBcbIigHkSYHomK1XMhUE0 ubuiZ0boanJklc4LCCVokCFLKk1+oKLyoZcBlaXmFYk6rDC4EOMn9ayynoEkRxYgcvTH lHft+8NEKJSYUzlLgiH7sH+arxo0cwEbYg6KiQc3CgakXa4lEf74mpT07xwCd+nxsN6S A9fRGBukdmfLhhugngKaXKrsKD9YW4uGqhjwZ13WEEuCKie17SUMn/UTD+qI4jt9xfRB aYFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JYwpb2hY; spf=pass (google.com: domain of gcc-patches-return-460892-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460892-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 c64si3204979pfl.530.2017.08.24.11.21.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Aug 2017 11:21:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-460892-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.s=default header.b=JYwpb2hY; spf=pass (google.com: domain of gcc-patches-return-460892-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460892-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:date:message-id:mime-version:content-type; q=dns; s= default; b=XgMWH2+m7BlrT1Vkm7ensCtAyvVPONc2rJkHXMHwZttdbTiW06k8e hCapSDTnt8mKOKm+Be7qeBsPs0Qi/Z00H8a1rTEJsNIyBTM2BEtuNBVOTGuffDO+ CvbuuTwBK9MuaIs/l0yvcYtHcQ4wlDNJtaZYP4oXeq5E+EgVQlXgp8= 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:date:message-id:mime-version:content-type; s= default; bh=EbQaoBgKN8UOafiDtAdIY0GcvDo=; b=JYwpb2hYOSV6Z4YbS4hn 4GXytBsbJSVViAxjGp2yK0hXPEHiCSpzVCXDneXBAyPPgwpOtdU109mZKuBlZnrM 0IFDnOfkozT4NUOG/nZBDt1OGzmGNwORDxYY6nJv/SrfyHGJB9p5y6aHursze4Ia 4vCFEpPSOP+m8piZQcnC3KA= Received: (qmail 53723 invoked by alias); 24 Aug 2017 18:21:44 -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 53271 invoked by uid 89); 24 Aug 2017 18:21:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=4897, 11617 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, 24 Aug 2017 18:21:41 +0000 Received: by mail-wm0-f48.google.com with SMTP id b189so1599694wmd.0 for ; Thu, 24 Aug 2017 11:21:41 -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:date:message-id :user-agent:mime-version; bh=UVoYnMFI7Y7+iulWbctMPmrUh3TQg76doGqMoOuYjLQ=; b=E5XZmdvn31NkZzD8kXBhLBx2ttm7kGYym+XPu6biyvkB5CgPBP9deYozkhuUjpMNoW O3xkWSiYcx7HTUSV0epqyZRkMCZG1uNxwLrmiPntK/PQ4Bre5O0wiqy5hcSM86b194di ZtissiQzIMJdwR/xouXl4FAdoikT0mTjHjNNC1m3hMvHHGCYAnzFyxoyrLi5Xwzo+x9j kBoGc3K17ez4RNUh3ggpucNJJbb1fNd1rexLGgOl8z0lGaZ4rsjA7XPHofQHLBvU3D0Y 8giCNV/gFGcOFz2DRpKIyiwDfpyp3KqpDfjYkNrFpv014zh/mFMLCbas0Wi0qO29IBR/ QXZw== X-Gm-Message-State: AHYfb5hqpMrAiOWGxozSTzSNRIROGrW+o3oic/7aidLH6WW8AcaFb+wi aGkpgV2PAzEcDFbWipsjnA== X-Received: by 10.28.107.69 with SMTP id g66mr4775248wmc.119.1503598899024; Thu, 24 Aug 2017 11:21:39 -0700 (PDT) Received: from localhost ([95.145.139.63]) by smtp.gmail.com with ESMTPSA id 123sm5577630wmt.14.2017.08.24.11.21.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Aug 2017 11:21:38 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Drop df_ from df_read_modify_subreg_p Date: Thu, 24 Aug 2017 19:21:36 +0100 Message-ID: <87378ghln3.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 ...it's really a general RTL predicate, rather than something that depends on the DF state. Thanks to Segher for the suggestion. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2017-08-24 Richard Sandiford gcc/ * df.h (df_read_modify_subreg_p): Remove in favor of... * rtl.h (read_modify_subreg_p): ...this new function. Take a const_rtx instead of an rtx. * cprop.c (local_cprop_find_used_regs): Update accordingly. * df-problems.c (df_word_lr_mark_ref): Likewise. * ira-lives.c (mark_pseudo_reg_live): Likewise. (mark_pseudo_reg_dead): Likewise. (mark_ref_dead): Likewise. * reginfo.c (init_subregs_of_mode): Likewise. * sched-deps.c (sched_analyze_1): Likewise. * df-scan.c (df_def_record_1): Likewise. (df_uses_record): Likewise. (df_read_modify_subreg_p): Remove in favor of... * rtlanal.c (read_modify_subreg_p): ...this new function. Take a const_rtx instead of an rtx. Index: gcc/df.h =================================================================== --- gcc/df.h 2017-08-24 19:20:31.055856350 +0100 +++ gcc/df.h 2017-08-24 19:20:31.265856538 +0100 @@ -1080,7 +1080,6 @@ extern unsigned int df_hard_reg_used_cou extern bool df_regs_ever_live_p (unsigned int); extern void df_set_regs_ever_live (unsigned int, bool); extern void df_compute_regs_ever_live (bool); -extern bool df_read_modify_subreg_p (rtx); extern void df_scan_verify (void); Index: gcc/rtl.h =================================================================== --- gcc/rtl.h 2017-08-24 19:20:31.055856350 +0100 +++ gcc/rtl.h 2017-08-24 19:20:31.266856539 +0100 @@ -2176,6 +2176,7 @@ extern unsigned int subreg_lsb_1 (machin unsigned int); extern unsigned int subreg_size_offset_from_lsb (unsigned int, unsigned int, unsigned int); +extern bool read_modify_subreg_p (const_rtx); /* Return the subreg byte offset for a subreg whose outer mode is OUTER_MODE, whose inner mode is INNER_MODE, and where there are @@ -2800,7 +2801,7 @@ partial_subreg_p (machine_mode outermode } /* Likewise return true if X is a subreg that is smaller than the inner - register. Use df_read_modify_subreg_p to test whether writing to such + register. Use read_modify_subreg_p to test whether writing to such a subreg preserves any part of the inner register. */ inline bool Index: gcc/cprop.c =================================================================== --- gcc/cprop.c 2017-08-24 19:20:31.055856350 +0100 +++ gcc/cprop.c 2017-08-24 19:20:31.264856537 +0100 @@ -1161,7 +1161,7 @@ local_cprop_find_used_regs (rtx *xptr, v return; case SUBREG: - if (df_read_modify_subreg_p (x)) + if (read_modify_subreg_p (x)) return; break; Index: gcc/df-problems.c =================================================================== --- gcc/df-problems.c 2017-08-24 19:20:31.055856350 +0100 +++ gcc/df-problems.c 2017-08-24 19:20:31.264856537 +0100 @@ -2819,7 +2819,7 @@ df_word_lr_mark_ref (df_ref ref, bool is return true; if (GET_CODE (orig_reg) == SUBREG - && df_read_modify_subreg_p (orig_reg)) + && read_modify_subreg_p (orig_reg)) { gcc_assert (DF_REF_FLAGS_IS_SET (ref, DF_REF_PARTIAL)); if (subreg_lowpart_p (orig_reg)) Index: gcc/ira-lives.c =================================================================== --- gcc/ira-lives.c 2017-08-24 19:20:31.055856350 +0100 +++ gcc/ira-lives.c 2017-08-24 19:20:31.265856538 +0100 @@ -364,7 +364,7 @@ mark_hard_reg_live (rtx reg) static void mark_pseudo_reg_live (rtx orig_reg, unsigned regno) { - if (df_read_modify_subreg_p (orig_reg)) + if (read_modify_subreg_p (orig_reg)) { mark_pseudo_regno_subword_live (regno, subreg_lowpart_p (orig_reg) ? 0 : 1); @@ -489,7 +489,7 @@ mark_hard_reg_dead (rtx reg) static void mark_pseudo_reg_dead (rtx orig_reg, unsigned regno) { - if (df_read_modify_subreg_p (orig_reg)) + if (read_modify_subreg_p (orig_reg)) { mark_pseudo_regno_subword_dead (regno, subreg_lowpart_p (orig_reg) ? 0 : 1); @@ -515,7 +515,7 @@ mark_ref_dead (df_ref def) if (DF_REF_FLAGS_IS_SET (def, DF_REF_PARTIAL) && (GET_CODE (orig_reg) != SUBREG || REGNO (reg) < FIRST_PSEUDO_REGISTER - || !df_read_modify_subreg_p (orig_reg))) + || !read_modify_subreg_p (orig_reg))) return; if (REGNO (reg) >= FIRST_PSEUDO_REGISTER) Index: gcc/reginfo.c =================================================================== --- gcc/reginfo.c 2017-08-24 19:20:31.055856350 +0100 +++ gcc/reginfo.c 2017-08-24 19:20:31.265856538 +0100 @@ -1356,7 +1356,7 @@ init_subregs_of_mode (void) df_ref def; FOR_EACH_INSN_DEF (def, insn) if (DF_REF_FLAGS_IS_SET (def, DF_REF_PARTIAL) - && df_read_modify_subreg_p (DF_REF_REG (def))) + && read_modify_subreg_p (DF_REF_REG (def))) record_subregs_of_mode (DF_REF_REG (def), true); } } Index: gcc/sched-deps.c =================================================================== --- gcc/sched-deps.c 2017-08-24 19:20:31.055856350 +0100 +++ gcc/sched-deps.c 2017-08-24 19:20:31.267856540 +0100 @@ -2419,7 +2419,7 @@ sched_analyze_1 (struct deps_desc *deps, { if (GET_CODE (dest) == STRICT_LOW_PART || GET_CODE (dest) == ZERO_EXTRACT - || df_read_modify_subreg_p (dest)) + || read_modify_subreg_p (dest)) { /* These both read and modify the result. We must handle them as writes to get proper dependencies for following Index: gcc/df-scan.c =================================================================== --- gcc/df-scan.c 2017-08-24 19:20:31.055856350 +0100 +++ gcc/df-scan.c 2017-08-24 19:20:31.265856538 +0100 @@ -2623,23 +2623,6 @@ df_ref_record (enum df_ref_class cl, } -/* A set to a non-paradoxical SUBREG for which the number of word_mode units - covered by the outer mode is smaller than that covered by the inner mode, - is a read-modify-write operation. - This function returns true iff the SUBREG X is such a SUBREG. */ - -bool -df_read_modify_subreg_p (rtx x) -{ - unsigned int isize; - - if (!partial_subreg_p (x)) - return false; - isize = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))); - return isize > REGMODE_NATURAL_SIZE (GET_MODE (SUBREG_REG (x))); -} - - /* Process all the registers defined in the rtx pointed by LOC. Autoincrement/decrement definitions will be picked up by df_uses_record. Any change here has to be matched in df_find_hard_reg_defs_1. */ @@ -2695,7 +2678,7 @@ df_def_record_1 (struct df_collection_re } else if (GET_CODE (dst) == SUBREG && REG_P (SUBREG_REG (dst))) { - if (df_read_modify_subreg_p (dst)) + if (read_modify_subreg_p (dst)) flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL; flags |= DF_REF_SUBREG; @@ -2909,7 +2892,7 @@ df_uses_record (struct df_collection_rec switch (GET_CODE (dst)) { case SUBREG: - if (df_read_modify_subreg_p (dst)) + if (read_modify_subreg_p (dst)) { df_uses_record (collection_rec, &SUBREG_REG (dst), DF_REF_REG_USE, bb, insn_info, Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-08-24 19:20:31.055856350 +0100 +++ gcc/rtlanal.c 2017-08-24 19:20:31.266856539 +0100 @@ -1357,6 +1357,22 @@ modified_in_p (const_rtx x, const_rtx in return 0; } + +/* Return true if X is a SUBREG and if storing a value to X would + preserve some of its SUBREG_REG. For example, on a normal 32-bit + target, using a SUBREG to store to one half of a DImode REG would + preserve the other half. */ + +bool +read_modify_subreg_p (const_rtx x) +{ + unsigned int isize; + + if (!partial_subreg_p (x)) + return false; + isize = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))); + return isize > REGMODE_NATURAL_SIZE (GET_MODE (SUBREG_REG (x))); +} /* Helper function for set_of. */ struct set_of_data