From patchwork Thu Jan 4 10:06:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 123399 Delivered-To: patch@linaro.org Received: by 10.80.135.92 with SMTP id 28csp6524928edv; Thu, 4 Jan 2018 02:07:17 -0800 (PST) X-Google-Smtp-Source: ACJfBot7ZGdBbz5ICKwcxZQ97aZl2+dpHXCM3HAn5yTocNrUFhNmGCk18Qb1VXUxP3S5DTv8RTI+ X-Received: by 10.98.104.194 with SMTP id d185mr4203485pfc.155.1515060437826; Thu, 04 Jan 2018 02:07:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515060437; cv=none; d=google.com; s=arc-20160816; b=gtHIR4R3S0QZ9zXhoMwyOePusPDB3qYfjIAF/LkTyV4UalB+Kxbfej7dbk593elexE I3fYMPq60fnXSlMqkCFv84WDpLZVDprQExjcGtEkJ3837an93tVmPKJ3HiuCQ2B6MDhD ty7jhj1aaEs7UYkNYpSzgGrJKvsf44fYBcuq0ji6p7qDj1otkz9jbboELOjunw8qdt6m HDw9YrWWJCWuV8RzeP9ON+gO/t36wysmu0BLeviDG3L36ok6QYezPJKeW5XkM3aYyyvf Udou62N90I/K343bDcM+3SSwAbPFRhhic3XXMALB3Mhv//aPjpgoIdGzGoQXfEZUFNzv LDzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date: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=RLF8xhcW6L9iLI1eYSWhf44I2CLpE46a4QrISV9BLOo=; b=x0xqtreGNsVz7Qp6RPsYZyNdJgqZQboWy2IzxHqqz3/2HE3R8uwSzyvLbDsWjFz6O8 RMswpFB0vyWG1utldNBmO4BDxk+HOjYrcWqjuaX8HsjPKHAcHKHi2xsvMJLL03/CrInW OIhYZjxPYynsBOltU+TpNaJBzSUWRMW+lYS366rf+kwGIFjy0oKeaMZLLeF5FtLiiSmo 8EybU7wSjI1So9dI/tQ1v8eSkQKrpS5Etp5/j3AaGwymeJ0e8mbLadrwjnFHFq4hZwox 5uq5YodDJPeGcMDWSHanPvy1OGyQcnx1OyQNN9ujEXfz1x/dwRIYoy5fY1h9SLkdCjb2 6r7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nUsvp+qW; spf=pass (google.com: domain of gcc-patches-return-470127-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470127-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 p1si2070018pld.669.2018.01.04.02.07.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 02:07:17 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-470127-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=nUsvp+qW; spf=pass (google.com: domain of gcc-patches-return-470127-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470127-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:date:message-id:mime-version:content-type; q=dns; s= default; b=eMsR9lZMG1x2ABAlgRfEBY9Zdb8HU9wsdROMtpVj2dAzlmscJBGPM zTM4P/Sl02+IHA7jnSPdkjl5Ev4/b6jgFjx6mOXCDKYOXw1aSZ+VPKVmBSPZpFob KabZrPwF9Maw2M8akgLgiynMJ3xqMMmW95NlkVuv+zMWagpGEso3w8= 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:date:message-id:mime-version:content-type; s= default; bh=gBnHMNqc2s6lI20lMaA4mWw4jr4=; b=nUsvp+qWPpieWj913z5I vBkvvJQdKwUqTL3Rvhtl0U/ZcUrLAphK8OnLyhIJPvj+iaFTX6TngTCHf2u0tSB9 5pFF2Crf41fnCqTyosagoHF1beU3ohd1lipzoMdoUNvWfwmlbg2IQHQB6OxU4vZV hrlOZcR6k22HbyS0AoGakEM= Received: (qmail 54796 invoked by alias); 4 Jan 2018 10:07:03 -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 54776 invoked by uid 89); 4 Jan 2018 10:07:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.1 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=positions 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; Thu, 04 Jan 2018 10:07:01 +0000 Received: by mail-wm0-f51.google.com with SMTP id g130so1469186wme.0 for ; Thu, 04 Jan 2018 02:07:00 -0800 (PST) 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:date:message-id :user-agent:mime-version; bh=RLF8xhcW6L9iLI1eYSWhf44I2CLpE46a4QrISV9BLOo=; b=BFhBW9d4emhMDoJZluSeINVkto5oclzmp/JCSN52/NRriVKawDjYnpjV+1Svm3S6Eg DqS/efY8f0AngQKMQwPdREU24JrnU+qxR+EeXNclI/CnRrSK1AFJxpRGwrkNaF5vFsfx KALwkomJw3phE3ZggkOs342EKF90cT5J3OAbp3arfwtMeYLstyaCbFgKOA6Fs/8MYHay Kt5BLykNvdcOAAVDz7BHEBHKKR/DXWkz2Lu8ZXFg0B6Mi6YoShGBSyffchYYyLm8WuvY JTOHthJI5Cq1c+uO+yU2Ygjgrj0cY5CRNkEErZOEdU1Cl5g+jcVWVxtSSponZaP8BNX6 JPzQ== X-Gm-Message-State: AKGB3mKbTWwjbPdz1AgjQWuFnG+M8VCBf7nJ4Oq52e/JCfWrl2KdGyLG irjDL26UF/LxkRtRBCMBWY1WU28/018= X-Received: by 10.28.153.209 with SMTP id b200mr3427566wme.10.1515060418944; Thu, 04 Jan 2018 02:06:58 -0800 (PST) Received: from localhost ([95.144.14.233]) by smtp.gmail.com with ESMTPSA id f19sm2099188wmf.5.2018.01.04.02.06.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jan 2018 02:06:58 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Add tree_fits_uhwi_p tests to BIT_FIELD_REF folder Date: Thu, 04 Jan 2018 10:06:57 +0000 Message-ID: <87k1wyhr9a.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 The first BIT_FIELD_REF folding pattern assumed without checking that operands satisfy tree_fits_uhwi_p. The second pattern does check this: /* On constants we can use native encode/interpret to constant fold (nearly) all BIT_FIELD_REFs. */ if (CONSTANT_CLASS_P (arg0) && can_native_interpret_type_p (type) && BITS_PER_UNIT == 8 && tree_fits_uhwi_p (op1) && tree_fits_uhwi_p (op2)) so this patch adds the checks to the first pattern too. This is needed for POLY_INT_CST bit positions. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. Also tested by comparing the before and after assembly output for at least one target per CPU directory. OK to install? Richard 2018-01-04 Richard Sandiford gcc/ * fold-const.c (fold_ternary_loc): Check tree_fits_uhwi_p before using tree_to_uhwi. Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2018-01-03 21:42:34.349039784 +0000 +++ gcc/fold-const.c 2018-01-04 10:06:02.165809202 +0000 @@ -11643,7 +11643,9 @@ fold_ternary_loc (location_t loc, enum t if (TREE_CODE (arg0) == VECTOR_CST && (type == TREE_TYPE (TREE_TYPE (arg0)) || (TREE_CODE (type) == VECTOR_TYPE - && TREE_TYPE (type) == TREE_TYPE (TREE_TYPE (arg0))))) + && TREE_TYPE (type) == TREE_TYPE (TREE_TYPE (arg0)))) + && tree_fits_uhwi_p (op1) + && tree_fits_uhwi_p (op2)) { tree eltype = TREE_TYPE (TREE_TYPE (arg0)); unsigned HOST_WIDE_INT width = tree_to_uhwi (TYPE_SIZE (eltype));