From patchwork Mon Oct 23 17:09:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116768 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4876050qgn; Mon, 23 Oct 2017 10:10:24 -0700 (PDT) X-Received: by 10.84.202.194 with SMTP id q2mr10939013plh.19.1508778624157; Mon, 23 Oct 2017 10:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508778624; cv=none; d=google.com; s=arc-20160816; b=0mos9x7ZYo0u+ACJTwbheXXfz6VnHmhNKsUIR8rEkIRdoLCdj+pU8eA9wZbeS6nq95 JHB2xIa4H/WAxXAgA9WbviY6lqIC1pHBVGfkmpnUr7oXuWz8Ag35MgozVjkr+vEJnmnC sDzsd2Ha8Q7SJ7SJ3zuCxij7/DKMMHK8cJQNgGrItYk3YM+kGRs5aOpN3ikkZvoIkHRg RP1mpiwb0f/6z2Z5f0LgtF/vy2XETLkVA/dlk6RaUxZELWCblj8RZhkngWT3sWljfCSf dfzjvwZQAG1RZ5RHCiYhRgNdGsvmn/Cu0NuavnIoiDX/ZX0yzDbg3HV3KXoH3qLzDya1 +9FQ== 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=xDxkXhK7PrUwRaSSd1cRM0feaqB6GEdFl63SjSMKDko=; b=Ck5Vs+pBa8pgOokd+eHJ7c+lGc1+tQoIZxu6wpm61sTmarGaUXGsUDDiaS+5vlS1ok AnbxgyTylWJYenvWT7kpGFIu/j0OfdhrCWfkSp5XT1bqxL4/iV8NzDSJY1yQxK25ayIl lQym5IakFCx+C/rXvBAosWnHkPTex6M1v1Ujyk/8/rv3fCl0wNJJ4WwmcQDBRk2CxxrQ I4QrnqoKO2xfmnYV4Faj635tG1U+PPZ8TizB+V/L6vTx/5+5VxhAtPYf9WenjPKpse5T PVBcZvqgKjEHRTikty1BCSouq8jg4fe218g/MQ9U/68eMXUT1P1EWIjDofanHT2KaqQg tecw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=u1nFyc/1; spf=pass (google.com: domain of gcc-patches-return-464800-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464800-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 z12si5172950pgc.582.2017.10.23.10.10.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:10:24 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464800-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=u1nFyc/1; spf=pass (google.com: domain of gcc-patches-return-464800-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464800-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=IRfrW5mtfxXCNmmTg9BwtPB9F1rNK 9E6B3zB/BkVeijwuIMsUUd6egXdCSng+/YJMHywywd7DG08rEaY0xEKwtiznSRCo ORMI1u5I3U9/D6wyYCRAEBCgYKNjh8yQdJDwYyKalX4VV6FbPYr6w5Cgw8CGpRC5 f73gFnQ+F8xzj4= 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=8O16DcNtvX2xto8W1qGTOh/civ0=; b=u1n Fyc/1U/R4W4zPwoYpdUAwd3zE2lNWN/5BX/6Z7O2qSFOewVq4sw4dwkDJZTAGtTq 5ct8oqgKWAUibYD+9uJvu20GNUSwP81WXsnNh39uhIp8yB43zoJVSbGTwYXLaic+ igI+1tlkDp/NpKUF1qb/RQPvf7epxpyZWm0MnmAI= Received: (qmail 5416 invoked by alias); 23 Oct 2017 17:09:46 -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 5395 invoked by uid 89); 23 Oct 2017 17:09:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 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=Been, 024 X-HELO: mail-wm0-f54.google.com Received: from mail-wm0-f54.google.com (HELO mail-wm0-f54.google.com) (74.125.82.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:09:44 +0000 Received: by mail-wm0-f54.google.com with SMTP id u138so11220389wmu.4 for ; Mon, 23 Oct 2017 10:09:44 -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=xDxkXhK7PrUwRaSSd1cRM0feaqB6GEdFl63SjSMKDko=; b=Zagy5uJH6n9W4wuLxeAybxWE8qpYI5P0aniPj75RleJ7LiDSTg+OI9W9dAi5zezePM Eg7hdXcwKOBCAiASSsc2ttPcgMDTHger+YHF1dDPhYdxvmrZC4mBdCGZ7w6V5vPQxzff ABTE62H7Lv3+cPr17ZguhCiIYPcTIYmZQiSCkqyg14ra4c0/VPDD49vWDBQK1J5GQDZh fKvOSYN5zxLR70AhVkcfsNyuPSYfx+uHR+1gOc/9qHQxWEqyPT4jvKlGzV5q3yHwIiPW 0lHp8rC5mqp0VPbioGAh+KyLmW/hi20tOS4sIbsIkIYaXITCEMHDaoeLDEDyZtEdl6FZ FCdw== X-Gm-Message-State: AMCzsaWwgkl8HbuJI4Epp/hbEks2Y9/f7KkmF3S3z4FW9HNbNaS+K53L E0rQHhxJ233rG7vdteaqLMKsRFPVUQ0= X-Google-Smtp-Source: ABhQp+Qh3rwknkpTU0wOATBA80EPesohQYvjQdyujpiUnVQw4Q4zY10i+eSTCFeZxz+vLhI5hZPAig== X-Received: by 10.28.232.138 with SMTP id f10mr5659133wmi.130.1508778582136; Mon, 23 Oct 2017 10:09:42 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id v23sm628359wmh.8.2017.10.23.10.09.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:09:41 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [024/nnn] poly_int: ira subreg liveness tracking References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:09:40 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87zi8hpz8r.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Normmaly the IRA-reload interface tries to track the liveness of individual bytes of an allocno if the allocno is sometimes written to as a SUBREG. This isn't possible for variable-sized allocnos, but it doesn't matter because targets with variable-sized registers should use LRA instead. This patch adds a get_subreg_tracking_sizes function for deciding whether it is possible to model a partial read or write. Later patches make it return false if anything is variable. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * ira.c (get_subreg_tracking_sizes): New function. (init_live_subregs): Take an integer size rather than a register. (build_insn_chain): Use get_subreg_tracking_sizes. Update calls to init_live_subregs. Index: gcc/ira.c =================================================================== --- gcc/ira.c 2017-10-23 17:11:43.647074065 +0100 +++ gcc/ira.c 2017-10-23 17:11:59.074107016 +0100 @@ -4040,16 +4040,27 @@ pseudo_for_reload_consideration_p (int r return (reg_renumber[regno] >= 0 || ira_conflicts_p); } -/* Init LIVE_SUBREGS[ALLOCNUM] and LIVE_SUBREGS_USED[ALLOCNUM] using - REG to the number of nregs, and INIT_VALUE to get the - initialization. ALLOCNUM need not be the regno of REG. */ +/* Return true if we can track the individual bytes of subreg X. + When returning true, set *OUTER_SIZE to the number of bytes in + X itself, *INNER_SIZE to the number of bytes in the inner register + and *START to the offset of the first byte. */ +static bool +get_subreg_tracking_sizes (rtx x, HOST_WIDE_INT *outer_size, + HOST_WIDE_INT *inner_size, HOST_WIDE_INT *start) +{ + rtx reg = regno_reg_rtx[REGNO (SUBREG_REG (x))]; + *outer_size = GET_MODE_SIZE (GET_MODE (x)); + *inner_size = GET_MODE_SIZE (GET_MODE (reg)); + *start = SUBREG_BYTE (x); + return true; +} + +/* Init LIVE_SUBREGS[ALLOCNUM] and LIVE_SUBREGS_USED[ALLOCNUM] for + a register with SIZE bytes, making the register live if INIT_VALUE. */ static void init_live_subregs (bool init_value, sbitmap *live_subregs, - bitmap live_subregs_used, int allocnum, rtx reg) + bitmap live_subregs_used, int allocnum, int size) { - unsigned int regno = REGNO (SUBREG_REG (reg)); - int size = GET_MODE_SIZE (GET_MODE (regno_reg_rtx[regno])); - gcc_assert (size > 0); /* Been there, done that. */ @@ -4158,19 +4169,26 @@ build_insn_chain (void) && (!DF_REF_FLAGS_IS_SET (def, DF_REF_CONDITIONAL))) { rtx reg = DF_REF_REG (def); + HOST_WIDE_INT outer_size, inner_size, start; - /* We can model subregs, but not if they are - wrapped in ZERO_EXTRACTS. */ + /* We can usually track the liveness of individual + bytes within a subreg. The only exceptions are + subregs wrapped in ZERO_EXTRACTs and subregs whose + size is not known; in those cases we need to be + conservative and treat the definition as a partial + definition of the full register rather than a full + definition of a specific part of the register. */ if (GET_CODE (reg) == SUBREG - && !DF_REF_FLAGS_IS_SET (def, DF_REF_ZERO_EXTRACT)) + && !DF_REF_FLAGS_IS_SET (def, DF_REF_ZERO_EXTRACT) + && get_subreg_tracking_sizes (reg, &outer_size, + &inner_size, &start)) { - unsigned int start = SUBREG_BYTE (reg); - unsigned int last = start - + GET_MODE_SIZE (GET_MODE (reg)); + HOST_WIDE_INT last = start + outer_size; init_live_subregs (bitmap_bit_p (live_relevant_regs, regno), - live_subregs, live_subregs_used, regno, reg); + live_subregs, live_subregs_used, regno, + inner_size); if (!DF_REF_FLAGS_IS_SET (def, DF_REF_STRICT_LOW_PART)) @@ -4255,18 +4273,20 @@ build_insn_chain (void) if (regno < FIRST_PSEUDO_REGISTER || pseudo_for_reload_consideration_p (regno)) { + HOST_WIDE_INT outer_size, inner_size, start; if (GET_CODE (reg) == SUBREG && !DF_REF_FLAGS_IS_SET (use, DF_REF_SIGN_EXTRACT - | DF_REF_ZERO_EXTRACT)) + | DF_REF_ZERO_EXTRACT) + && get_subreg_tracking_sizes (reg, &outer_size, + &inner_size, &start)) { - unsigned int start = SUBREG_BYTE (reg); - unsigned int last = start - + GET_MODE_SIZE (GET_MODE (reg)); + HOST_WIDE_INT last = start + outer_size; init_live_subregs (bitmap_bit_p (live_relevant_regs, regno), - live_subregs, live_subregs_used, regno, reg); + live_subregs, live_subregs_used, regno, + inner_size); /* Ignore the paradoxical bits. */ if (last > SBITMAP_SIZE (live_subregs[regno]))