From patchwork Mon Oct 23 11:25:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116700 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4529968qgn; Mon, 23 Oct 2017 04:25:19 -0700 (PDT) X-Received: by 10.159.216.131 with SMTP id s3mr9929376plp.434.1508757918958; Mon, 23 Oct 2017 04:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508757918; cv=none; d=google.com; s=arc-20160816; b=nhkZt9WbZQPnlU7juykcpXQFBLFdIaoS0W6krYJS39ULIbJzvB1jVENrdLj8G145kD 2YfJfuOWPKLZhVefWyslaMD7iGC2GgcqcDSKQ1CnnoQLF5tCg+T0z3ojyRc25F6XG7aF BqjWvNYuAs51eQ+2LwNJ0V7kj0U+0wf03XGp50xOWHzqmiqQ1yXn9W3wdroj7hwi9y20 HFhfTsZNlhj9hg7zfXU2vDeylkA0g15zcEnVbmbwPXC5C6/yQc2IHtlYhw3uLVFFLwQv FAxffCd6EjZ5sL3+wv4ovYIdlPI0mlK/FxI08my4y/fNlJF4nqB6YNAgLhZ7FJzeqWAt mjVQ== 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=79sgsr+cYZwHv686IdHOQJPoxhaCK83K9j/p9jZF0Jg=; b=llVlTnHILIQrOyDsK8jvVx930rt3l/KB9Jam0g3LQm4648RuIOWFO/JZsc6sr5iBHw Ck/jcSRNDa8WAhE8ba/Fke8fMKiwlCusdv6OEzuH46t6jg3FxDdgwOhPXV9QaaKR5TYN /ip8b+F27jUspJTtCmHRkSYTInfYnFD13W0rTPmMofZ0bCVOAWUApN7NtNuQooLHuysv Ao/EHaeLKo43lv1wAoU5OkCwUZ22EXc0HJzse1/xkP/9e99EIzzqP12UqgEvXrO5rhMp 0HcmhyLjoIvPKcLrmd10ZUXy39r5ebMIYErqVzpaXQLn+QdMKIsLSORIm+Z9yLfSR/fP KD4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=jQS0hL9C; spf=pass (google.com: domain of gcc-patches-return-464740-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464740-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 o28si4813212pgn.180.2017.10.23.04.25.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 04:25:18 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464740-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=jQS0hL9C; spf=pass (google.com: domain of gcc-patches-return-464740-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464740-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=wXoPMqMZPa2QVrxBbPxq/IFrcin8U tPE/gID5eJpkcTx/u4xRXg2s3SAC4eJIu3yA20ty5qdio2fJHxO+6A1RQASK0eUa qBh6LVkkfoOYJJ+6n2WL18CaWA20CS9JgTpW23P0aX8hpcAaVYcJg4X3VnmFBzQ2 DTtV5LjXmWA+dQ= 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=fAXMmgXyMYKnZWwc3c7A4WVJ5FM=; b=jQS 0hL9CV9BzqsQ3rzJQaHPEFnRIPm5hf4Ib79nTBbwv6G3hC4Iz218lCqY28mdEAVR skIHAAcqTkYSYsRH2RsDjzhDoSFc/I+m9Ecaus4XP1C0bFrZtFEHyBNCpsdJiBkD Ys2OGr+7AmUcASKZRN4Q5BUuAfXMZkUAO2yVDfew= Received: (qmail 66646 invoked by alias); 23 Oct 2017 11:25:07 -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 66631 invoked by uid 89); 23 Oct 2017 11:25:06 -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=Fall X-HELO: mail-wr0-f179.google.com Received: from mail-wr0-f179.google.com (HELO mail-wr0-f179.google.com) (209.85.128.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 11:25:05 +0000 Received: by mail-wr0-f179.google.com with SMTP id l8so4109452wre.12 for ; Mon, 23 Oct 2017 04:25:05 -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=79sgsr+cYZwHv686IdHOQJPoxhaCK83K9j/p9jZF0Jg=; b=KhGVKA2nn5MNhes41rXX9PoYaNqQu3ywvFEHMIiAZh+fMU0SQXOX+6yNZvnTRenIay IOktCBwEKLtTt7fBMQCpVpH6CyJSKg34imLQJSuimj8SL8FDqBZqxfA8PuxisBuC30vt YnSovlHfX2Al6JVi18GGktDAdSgkqn0NQg/ZncHrDmmYVPfNizUVEihU4tL265kvlHbi PhUZ6bA0X7kg7p8V2Ynie5SKFWAF+KsADsbz+QoOtJKUAzs92EXhs8fdMjUQ4HVKNEJv JvR42Z9C18pgYIxnd3WQGfx1PRnWGPJobTCBXKj13h44AsrMMH4+yj87ny1Is4hTQHmj s9gg== X-Gm-Message-State: AMCzsaXnbAlGvFoZDUHrrnQGhhEmE12Dxi3gNfejQzoLpSqa8Ix+7j4N QuC0QWfylbWjrFEVPAUD3a5qS8i3vos= X-Google-Smtp-Source: ABhQp+QeKR6pn1bO2IWdhlHYcjXX5+Dpes/oRHh3czlcjBJIWCEtbkhziCf8FD1aWYm4VgHftHgSvQ== X-Received: by 10.223.134.25 with SMTP id 25mr11669759wrv.186.1508757903257; Mon, 23 Oct 2017 04:25:03 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id w75sm3607492wmw.17.2017.10.23.04.25.02 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 04:25:02 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [13/nn] More is_a References: <87wp3mxgir.fsf@linaro.org> Date: Mon, 23 Oct 2017 12:25:00 +0100 In-Reply-To: <87wp3mxgir.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 12:14:36 +0100") Message-ID: <87d15ew1gz.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 alias.c:find_base_term and find_base_value checked: if (GET_MODE_SIZE (GET_MODE (src)) < GET_MODE_SIZE (Pmode)) but (a) comparing the precision seems more correct, since it's possible for modes to have the same memory size as Pmode but fewer bits and (b) the functions are called on arbitrary rtl, so there's no guarantee that we're handling an integer truncation. Since there's no point processing truncations of anything other than an integer, this patch checks that first. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * alias.c (find_base_value, find_base_term): Only process integer truncations. Check the precision rather than the size. Index: gcc/alias.c =================================================================== --- gcc/alias.c 2017-10-23 11:41:25.511925516 +0100 +++ gcc/alias.c 2017-10-23 11:44:27.544693078 +0100 @@ -1349,6 +1349,7 @@ known_base_value_p (rtx x) find_base_value (rtx src) { unsigned int regno; + scalar_int_mode int_mode; #if defined (FIND_BASE_TERM) /* Try machine-dependent ways to find the base term. */ @@ -1475,7 +1476,8 @@ find_base_value (rtx src) address modes depending on the address space. */ if (!target_default_pointer_address_modes_p ()) break; - if (GET_MODE_SIZE (GET_MODE (src)) < GET_MODE_SIZE (Pmode)) + if (!is_a (GET_MODE (src), &int_mode) + || GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (Pmode)) break; /* Fall through. */ case HIGH: @@ -1876,6 +1878,7 @@ find_base_term (rtx x) cselib_val *val; struct elt_loc_list *l, *f; rtx ret; + scalar_int_mode int_mode; #if defined (FIND_BASE_TERM) /* Try machine-dependent ways to find the base term. */ @@ -1893,7 +1896,8 @@ find_base_term (rtx x) address modes depending on the address space. */ if (!target_default_pointer_address_modes_p ()) return 0; - if (GET_MODE_SIZE (GET_MODE (x)) < GET_MODE_SIZE (Pmode)) + if (!is_a (GET_MODE (x), &int_mode) + || GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (Pmode)) return 0; /* Fall through. */ case HIGH: