From patchwork Mon Oct 23 11:30:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116709 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4534337qgn; Mon, 23 Oct 2017 04:30:49 -0700 (PDT) X-Received: by 10.159.208.71 with SMTP id w7mr9984296plz.228.1508758249572; Mon, 23 Oct 2017 04:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508758249; cv=none; d=google.com; s=arc-20160816; b=HQ0V+Rx0qjGNOeupWMTPlx0Ksqzc81T3hB3M/Bs86NrJSKWIZA466Hmnonr3agj0Ba HvTzZxVTuOhgG2JGWX21x4jef/ms/G+nx2Ni8gyOFbA8OyfSYKEDzN92VXUaiJucMRKP yD39EO8rg0fG+NDmfdPkMZlxZmMaWIO0evJfvJyc394JhtOAO90KxJ8hWS+cNGWXZXiO pZ5CsbhU6CEFpvQy2BjZo7Z4URueTm3YC+us7qwPy/mlH/GZM3KCGPtiMS0DFEPXEXy2 OBXNg6Fj8Qf0nnPO/qn0zswtBNc4kUMIzxz4/D7SJVlcc/fKBte2MoV+Od3jYDLjJpyj mUpA== 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=WpN+A08NPXP97ejEYDxLslX3axDzYStutxgY/fWMJSg=; b=ByXvVskDg4WmpVzuGy2ogvfzY3REdicySFetUsHBB4f8a/ifYBHtkuofV5npyx/13k qeqd07ZsLgFqympegLHAEzTjHT4u6mMjz0kp3xlHJIr/GwkWH3o8b1aqVEZAuGcCmCxW /BKbyWpqjS6fJiR9Dowe8ihqWzJI87FNvSIdpuNpatdmYKwZN9epFpDwEjvzwkBBIXTi n9KDUIZSd8ElJZxeJWw+R8vrYqtsRHQktR6oSydJ97PP6rqxNmVOGBGKYxMf/EWoVnst SLmlSD9yo4ZvqLe8tAjwzwSMod6az5J8J9s2cHeKjTPnu3JT0t4xq69RnzI5J7VqxPXQ LnKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=EgbtS0rH; spf=pass (google.com: domain of gcc-patches-return-464749-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464749-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 d5si4756372pgq.109.2017.10.23.04.30.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 04:30:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464749-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=EgbtS0rH; spf=pass (google.com: domain of gcc-patches-return-464749-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464749-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=cZm3aKZYQys70oIhlqF/yddxteZDu h/Mk/orV1DR2mAaPj78YIv2Rih0wQYqXT4KnGU4BR2RvaxKN7+QLHRHHM0ts2eFs hdFGtIB2e+ZZ4MDsuEzICeP3tQ1rDL7juj0mpmgPTvo36TZ3n4v+QuvvFPPRUhtn P+MPT9t+0czcDY= 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=DH/SZT9mujimEGSV/vDn6goTjoI=; b=Egb tS0rH450LdE5NN4x+9+G2MjWYAr2Dua2wCJT2VVR5QXeugSBYgUf8nLc+Nj9sM8c qySOCjjlFUyHeCV61Lqbqv3AijXG2iJmJGOuDGTlv6xFAuvJ3OEl/ToXZZf6SgaF fO8p2ZCgA5xH8qdyZLCoirRFO24mVbCH6uuTf3jU= Received: (qmail 96717 invoked by alias); 23 Oct 2017 11:30:36 -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 96663 invoked by uid 89); 23 Oct 2017 11:30:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.6 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=maxsize, tweak X-HELO: mail-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 11:30:26 +0000 Received: by mail-wm0-f45.google.com with SMTP id t69so8860760wmt.2 for ; Mon, 23 Oct 2017 04:30:16 -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=WpN+A08NPXP97ejEYDxLslX3axDzYStutxgY/fWMJSg=; b=sfTruU0iFYoW3x1jKB95fvPM18qRWnP/EBdyNWLdhmalYY5QL/houJoXbFq6Yy+B4/ YoLKYEMvqavG/gOTsF8z4VsVI7fxbjJYhbclAfaMgh98iwuh9cabZO0Rt7D6KfeoB7ft uTbvcgSnQUzv8N2BeHRwOpjucHRmOeuYHE5DbJUB5pGEX5I3sOgfGpoRImPiUZLVBAT4 gkSlQ/OIDcwddYZHNXT8vNMkC5a91r17paF2yBxPj7i2jGJlLaDqPV7s/PmCMFMmIWi8 O2f366ltrGTWDbZKkdmgv0DE9SyCjY7EG9cAsv3nzz6B/Z9OmtkrOqWQMKSLDKtottRR wbQw== X-Gm-Message-State: AMCzsaVGN34MYi7gTfCwplTsrQHtsAl9hBBr+MKJuqYYYRxqSMu6GAxV sIsTnC/SD8hPKmCCiyJR4qT4cmcEFTk= X-Google-Smtp-Source: ABhQp+RnA9iwKgq5Eft6haTGOgDU1INsqIIJSCTERamqBK2LUv+3LrUfpeHpf5FzerDw4LhPXuMvug== X-Received: by 10.28.140.15 with SMTP id o15mr4930455wmd.8.1508758214830; Mon, 23 Oct 2017 04:30:14 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id z35sm18106799wrc.9.2017.10.23.04.30.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 04:30:14 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [21/nn] Minor vn_reference_lookup_3 tweak References: <87wp3mxgir.fsf@linaro.org> Date: Mon, 23 Oct 2017 12:30:12 +0100 In-Reply-To: <87wp3mxgir.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 12:14:36 +0100") Message-ID: <87efpuumnv.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The repeated checks for MEM_REF made this code hard to convert to poly_ints as-is. Hopefully the new structure also makes it clearer at a glance what the two cases are. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid repeated checks for MEM_REF. Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c 2017-10-23 11:47:03.852769480 +0100 +++ gcc/tree-ssa-sccvn.c 2017-10-23 11:47:44.596155858 +0100 @@ -2234,6 +2234,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree || offset % BITS_PER_UNIT != 0 || ref->size % BITS_PER_UNIT != 0) return (void *)-1; + at = offset / BITS_PER_UNIT; /* Extract a pointer base and an offset for the destination. */ lhs = gimple_call_arg (def_stmt, 0); @@ -2301,19 +2302,18 @@ vn_reference_lookup_3 (ao_ref *ref, tree copy_size = tree_to_uhwi (gimple_call_arg (def_stmt, 2)); /* The bases of the destination and the references have to agree. */ - if ((TREE_CODE (base) != MEM_REF - && !DECL_P (base)) - || (TREE_CODE (base) == MEM_REF - && (TREE_OPERAND (base, 0) != lhs - || !tree_fits_uhwi_p (TREE_OPERAND (base, 1)))) - || (DECL_P (base) - && (TREE_CODE (lhs) != ADDR_EXPR - || TREE_OPERAND (lhs, 0) != base))) + if (TREE_CODE (base) == MEM_REF) + { + if (TREE_OPERAND (base, 0) != lhs + || !tree_fits_uhwi_p (TREE_OPERAND (base, 1))) + return (void *) -1; + at += tree_to_uhwi (TREE_OPERAND (base, 1)); + } + else if (!DECL_P (base) + || TREE_CODE (lhs) != ADDR_EXPR + || TREE_OPERAND (lhs, 0) != base) return (void *)-1; - at = offset / BITS_PER_UNIT; - if (TREE_CODE (base) == MEM_REF) - at += tree_to_uhwi (TREE_OPERAND (base, 1)); /* If the access is completely outside of the memcpy destination area there is no aliasing. */ if (lhs_offset >= at + maxsize / BITS_PER_UNIT