From patchwork Mon Oct 23 11:27:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116705 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4532179qgn; Mon, 23 Oct 2017 04:28:09 -0700 (PDT) X-Received: by 10.99.109.2 with SMTP id i2mr11138671pgc.194.1508758089619; Mon, 23 Oct 2017 04:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508758089; cv=none; d=google.com; s=arc-20160816; b=Tgjl6DCUy6wXz8kGbvYRkh95xZzhuVl4gas4Jh79egQof329DMgUxsY/o0Mbki+SOK N2ahPe87qLqCvfWadRObfMlxW66CQxh6LsKGdnib9Rqs5z/Tpcr04yvDIXeQGJCUvllp BuW7pkGH+AbAeR4E2deqPeV1LFL9LdwpSiD5tb8t0LcczY2p7Wu4xtkJPmvc1LMmarTF rU1sIyzSZdub0J2BOUGEc2fXlo/WUTnCbNQo/f2/M+x/iZq1Oojsdz5px/EO6XUD2RXz pyiRjSKjQKUGjGgALsELyU2cm3FjVez97e6BoPUbEvD/vckhuRaGPJR2rqmx8kx95cU8 2K7Q== 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=QngU6WvKEmjBP0qy7IcEXVi0Ortqj0AWcRA0npr7u/c=; b=yL58y+OfTOaoOLWOysvS1xeHzr9TuvTvHNnaLJmzN11k29g12YS/BCb5IPfZw1KNUN aNEbeLxLB69AnL3OM0j698Trd9BG/H9E4FLNOI8SlltzEoo8SjXgpa5aUUOo8cg1Aurd nZV2Lj5NRE9x8fUiFrvwQ9JmdUVDyPB+rUhwY5CdhfESlL62SL0PKYcP89RYul3/tXb1 OxbQ8sg2ze/P0E2OJuEDU3syinDdwvflfd4nXRYLEyOEVDB2vF+tNHc9Wu08r1GRKylS hG8DxpmJmgyO7NWDwi4RaX80ZI0mh/mGeFMoo4T2YfLJi3VSrQYeFejgXmkwvPx6Pt7+ vFZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wdguhb1o; spf=pass (google.com: domain of gcc-patches-return-464745-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464745-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 g12si3962773plj.33.2017.10.23.04.28.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 04:28:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464745-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=wdguhb1o; spf=pass (google.com: domain of gcc-patches-return-464745-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464745-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=dJyqMMoNtFCJhM1j1chj+FdmWGW38 lFubhv361Qvhs1zkIey3yxjjXLHVRmp91HR3NG/kkSyN6ujXioUBj2GMilGqAXaW bUZF1eR1df9Izubxlmp9UVXANBevPOpgt4YIf0S56YoHp1CsbdU4znr1ZAoKqZcN 6j5JZiHMflA/eQ= 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=NfmM+t0dwTR3h4IGn3cPGYM48LM=; b=wdg uhb1oBq+zYnuW0eUJm0qfuZ/+fgP19AuRzBzaJguu6DBbJXTqs+FVeFgcYlXGuhA 2G6+xGMsnJ11gbdovhLo+zyMW+EQkxhW1j5K9qkFdMrrNr0fYcBM4dzBD6r+7Bsw 2SZ15dyWiL+ojQ7TtsSJRNk2d8i8Xpj1cVTI0BxM= Received: (qmail 85452 invoked by alias); 23 Oct 2017 11:27:55 -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 85442 invoked by uid 89); 23 Oct 2017 11:27:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=voi, multi-part X-HELO: mail-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 11:27:53 +0000 Received: by mail-wm0-f51.google.com with SMTP id u138so8832931wmu.5 for ; Mon, 23 Oct 2017 04:27:53 -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=QngU6WvKEmjBP0qy7IcEXVi0Ortqj0AWcRA0npr7u/c=; b=un4vTK6P/XU60r3evbRcwc1fqdc+w5AhYh9IrQNqhNvVTxFLztfFl06cKZ3qyKmQ6K ePqprUEEVzxWAnz+bYfXsmyAEeDLebQion9Up7ScfRgoMyELhaqbotLnAmWDFit9J1qr r2spPdrmW6hROBm8YWxLXWrUs/2rRIokPXX3oNKBfmbKCKX/8YCiV9YsSsEqPVgW/+1Q Dw5tPj2WaRWmPc8JqKvJIb6Pa7rwBVoyBpwnhSNNaiGESZ3UrbT/G7QP5VTlJcJXGVoH O3v7fWYEi67MIVGg1py86dK7yDXKpucZLHaWr5Jxhuq7NjBCnR2zU2svq49iPojn2P4A a2uw== X-Gm-Message-State: AMCzsaVc8uMhiry+FqNhUIcuiV8faMqRgH3UZJ04Pta9P5V01YBJyhZp socciD/ixSU2IdR1yQ78zjEWfJJnrso= X-Google-Smtp-Source: ABhQp+R5PrrDi/9c+jQ4zRQ9UA2K5GFB87jxaQ2yfp525ZcXQ313ADTOnXt/jhLjRiK1Ug4IH7X3Qg== X-Received: by 10.28.19.73 with SMTP id 70mr5152282wmt.87.1508758071438; Mon, 23 Oct 2017 04:27:51 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id t131sm2791320wmd.12.2017.10.23.04.27.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 04:27:50 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [17/nn] Turn var-tracking.c:INT_MEM_OFFSET into a function References: <87wp3mxgir.fsf@linaro.org> Date: Mon, 23 Oct 2017 12:27:49 +0100 In-Reply-To: <87wp3mxgir.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 12:14:36 +0100") Message-ID: <87vaj6umru.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This avoids the double evaluation mentioned in the comments and simplifies the change to make MEM_OFFSET variable. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * var-tracking.c (INT_MEM_OFFSET): Replace with... (int_mem_offset): ...this new function. (var_mem_set, var_mem_delete_and_set, var_mem_delete) (find_mem_expr_in_1pdv, dataflow_set_preserve_mem_locs) (same_variable_part_p, use_type, add_stores, vt_get_decl_and_offset): Update accordingly. Index: gcc/var-tracking.c =================================================================== --- gcc/var-tracking.c 2017-09-12 14:28:56.401824826 +0100 +++ gcc/var-tracking.c 2017-10-23 11:47:27.197231712 +0100 @@ -390,8 +390,15 @@ struct variable /* Pointer to the BB's information specific to variable tracking pass. */ #define VTI(BB) ((variable_tracking_info *) (BB)->aux) -/* Macro to access MEM_OFFSET as an HOST_WIDE_INT. Evaluates MEM twice. */ -#define INT_MEM_OFFSET(mem) (MEM_OFFSET_KNOWN_P (mem) ? MEM_OFFSET (mem) : 0) +/* Return MEM_OFFSET (MEM) as a HOST_WIDE_INT, or 0 if we can't. */ + +static inline HOST_WIDE_INT +int_mem_offset (const_rtx mem) +{ + if (MEM_OFFSET_KNOWN_P (mem)) + return MEM_OFFSET (mem); + return 0; +} #if CHECKING_P && (GCC_VERSION >= 2007) @@ -2336,7 +2343,7 @@ var_mem_set (dataflow_set *set, rtx loc, rtx set_src) { tree decl = MEM_EXPR (loc); - HOST_WIDE_INT offset = INT_MEM_OFFSET (loc); + HOST_WIDE_INT offset = int_mem_offset (loc); var_mem_decl_set (set, loc, initialized, dv_from_decl (decl), offset, set_src, INSERT); @@ -2354,7 +2361,7 @@ var_mem_delete_and_set (dataflow_set *se enum var_init_status initialized, rtx set_src) { tree decl = MEM_EXPR (loc); - HOST_WIDE_INT offset = INT_MEM_OFFSET (loc); + HOST_WIDE_INT offset = int_mem_offset (loc); clobber_overlapping_mems (set, loc); decl = var_debug_decl (decl); @@ -2375,7 +2382,7 @@ var_mem_delete_and_set (dataflow_set *se var_mem_delete (dataflow_set *set, rtx loc, bool clobber) { tree decl = MEM_EXPR (loc); - HOST_WIDE_INT offset = INT_MEM_OFFSET (loc); + HOST_WIDE_INT offset = int_mem_offset (loc); clobber_overlapping_mems (set, loc); decl = var_debug_decl (decl); @@ -4618,7 +4625,7 @@ find_mem_expr_in_1pdv (tree expr, rtx va for (node = var->var_part[0].loc_chain; node; node = node->next) if (MEM_P (node->loc) && MEM_EXPR (node->loc) == expr - && INT_MEM_OFFSET (node->loc) == 0) + && int_mem_offset (node->loc) == 0) { where = node; break; @@ -4683,7 +4690,7 @@ dataflow_set_preserve_mem_locs (variable /* We want to remove dying MEMs that don't refer to DECL. */ if (GET_CODE (loc->loc) == MEM && (MEM_EXPR (loc->loc) != decl - || INT_MEM_OFFSET (loc->loc) != 0) + || int_mem_offset (loc->loc) != 0) && mem_dies_at_call (loc->loc)) break; /* We want to move here MEMs that do refer to DECL. */ @@ -4727,7 +4734,7 @@ dataflow_set_preserve_mem_locs (variable if (GET_CODE (loc->loc) != MEM || (MEM_EXPR (loc->loc) == decl - && INT_MEM_OFFSET (loc->loc) == 0) + && int_mem_offset (loc->loc) == 0) || !mem_dies_at_call (loc->loc)) { if (old_loc != loc->loc && emit_notes) @@ -5254,7 +5261,7 @@ same_variable_part_p (rtx loc, tree expr else if (MEM_P (loc)) { expr2 = MEM_EXPR (loc); - offset2 = INT_MEM_OFFSET (loc); + offset2 = int_mem_offset (loc); } else return false; @@ -5522,7 +5529,7 @@ use_type (rtx loc, struct count_use_info return MO_CLOBBER; else if (target_for_debug_bind (var_debug_decl (expr))) return MO_CLOBBER; - else if (track_loc_p (loc, expr, INT_MEM_OFFSET (loc), + else if (track_loc_p (loc, expr, int_mem_offset (loc), false, modep, NULL) /* Multi-part variables shouldn't refer to one-part variable names such as VALUEs (never happens) or @@ -6017,7 +6024,7 @@ add_stores (rtx loc, const_rtx expr, voi rtx xexpr = gen_rtx_SET (loc, src); if (same_variable_part_p (SET_SRC (xexpr), MEM_EXPR (loc), - INT_MEM_OFFSET (loc))) + int_mem_offset (loc))) mo.type = MO_COPY; else mo.type = MO_SET; @@ -9579,7 +9586,7 @@ vt_get_decl_and_offset (rtx rtl, tree *d if (MEM_ATTRS (rtl)) { *declp = MEM_EXPR (rtl); - *offsetp = INT_MEM_OFFSET (rtl); + *offsetp = int_mem_offset (rtl); return true; } }