From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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 11:25:00 -0000 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 Content-Type: text/plain X-SW-Source: 2017-10/txt/msg01465.txt.bz2 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: