From patchwork Wed Sep 20 12:06:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 113104 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp684105qgf; Wed, 20 Sep 2017 05:06:44 -0700 (PDT) X-Received: by 10.99.179.66 with SMTP id x2mr1918668pgt.336.1505909204063; Wed, 20 Sep 2017 05:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505909204; cv=none; d=google.com; s=arc-20160816; b=IeGhXF6bHpvrU8oQG54OIWiZakfv7X5QD3TWUm/EmydImDFWNmaALz13Fp8kTtPHgf cKIYinWCMH+ZrbqP5ncsqC+GvcGB2TA0gJOJRCY0mWgOBq0pFFS4GCyrH3Z2XPYIo2PT Km9uCy9hKGxYeQIxe8NdY8i32S9vvhu5xVFsEB9oiRcJlLhnmk0F+IIU5bRWpIS+USUq n8XR+MNWql3Han+ZoapSSmClfvG9SDEcA47xvHj20TYUSCAQ2C9Cj0eW4QC8BTrFizip CRKJk8tG3WpVSo94Cx7Az59IrO8Jdnlf3V1sMPbII35aaERKMPlIBijyAbR+td0NRfc2 0MZw== 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=vSTn8IueWatcb+PyypuchG5I4k9d9NKaL9kFPlmS8t4=; b=tCVUWIkqIQDIHYYiWCX6+jNvU6WPvEeqIrE88vAczWry7s7EiuyF5UKiAAUKxmft3g gww/U6WylP3qLc4C6FBahTrba3dZQXS3o8/ExXTbBF8RuoR4sLcwUS8icOtbHMAK83Be Kxvyq3MpAAg0oBF3ouvGTC9I26a9ZLm1XdvMBAlf7P1ZAq9HS8wv/IBfxnYCm6et+V+b P58W8hyfIxbKLm8MGnvNBefEP1YayMMhuoACQ/9VY3XbVpVrBjSdfEEoIPoxFVQAqsOP VF8wAoTys2VwJuP6ae4qP9QHOy+JZyKDB2STFBL32AkGDV7qinrBIaBEmrbkCQckw574 MluA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=g/sSSoZM; spf=pass (google.com: domain of gcc-patches-return-462575-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462575-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 11si2949432pfi.308.2017.09.20.05.06.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 05:06:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462575-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=g/sSSoZM; spf=pass (google.com: domain of gcc-patches-return-462575-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462575-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=QBkPn9qH85GkSEVFqQykvU6UZlLrRn2X395fvgdNVyLyq5nCAgHZY +t1ddlygBdXMMj27HyXXlK14LOgwoiKqmC5MCABQghIdZloPxvH431lKbHyjtRTc rgKZ9agZqgCXCX9Tte+cW5nF3UFIyCiIxXVJFRfaWsQQlYj3wGfOCo= 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=8ZIPdR4g1ipMKPhpjQXjFIR4pGU=; b=g/sSSoZMzPvGavh6Ohp/ OzYSn74hRdKkyoUoPU3WVXjbMBUx7X4Z0+FUjRP5JVKn2fdB+11FE3xB1nA5ULd7 LqItBxrnU68FW05zBVLb1JWWQietBaGtF4rCXOOFK8kmWTxVzH1ftt/c5xKtJHIf 6ZqsWg0KeK1G51ffYSQfYa0= Received: (qmail 114305 invoked by alias); 20 Sep 2017 12:06:33 -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 113960 invoked by uid 89); 20 Sep 2017 12:06:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 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=20170830, sk:davids, H*r:threembb.co.uk, sk:david.s X-HELO: mail-wr0-f171.google.com Received: from mail-wr0-f171.google.com (HELO mail-wr0-f171.google.com) (209.85.128.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Sep 2017 12:06:30 +0000 Received: by mail-wr0-f171.google.com with SMTP id u96so1974615wrb.6 for ; Wed, 20 Sep 2017 05:06:30 -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:date:message-id :user-agent:mime-version; bh=vSTn8IueWatcb+PyypuchG5I4k9d9NKaL9kFPlmS8t4=; b=pgmPGjIX+wgEm3EBSjU6jy9I3ncFMj8uPl9gK83A6sXkvDzp83LNqdwQiJxa+xD3RS wWyo2WgSKXzsaqw0jIgti0BMzrcPalwWgsS3iOuXWo/4iV+vaeBHCS9abXoVIu6epIDB ImrHUAiaSOsYrrW4zF34FLWGa6yGbCf+ogQJBO4jps3S2+Ywnyo/LXQZWV7P2JxKbyFS wszQrPeAsMWy3oy36Mch+Xa9VXEzyLydG/Fnd5TXOZc5qKgK5dKbbNleYI8Z5BZDDOrJ gpwaGWA4MdgnO98XY6Cv8zwNENn/1qkE6xGOoo/wLiJET1AhdRznDvnHEOPBcuLlN4s0 3m9A== X-Gm-Message-State: AHPjjUgMfy2wuJXFX1iBY0l6JIfFeqdca45VqpAgyD4NoSKgkWnh3cnI +dSIQY2ES2xmLVejbtsUUFEUvH0kZxs= X-Google-Smtp-Source: AOwi7QAxG78pghH1XFlXKES1pnVFXS5PjKd11UAH1zAfFSBjsQgmLeAhmS4YdBd5utJ35oyyK9Xaag== X-Received: by 10.223.130.77 with SMTP id 71mr3927107wrb.247.1505909188111; Wed, 20 Sep 2017 05:06:28 -0700 (PDT) Received: from localhost (92.40.248.127.threembb.co.uk. [92.40.248.127]) by smtp.gmail.com with ESMTPSA id f140sm1531798wmd.12.2017.09.20.05.06.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Sep 2017 05:06:27 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: range_int_cst_p handling in extract_range_from_binary_expr_1 Date: Wed, 20 Sep 2017 13:06:24 +0100 Message-ID: <87vakd1sn3.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 extract_range_from_binary_expr_1 had: if (range_int_cst_p (&vr0) && range_int_cst_p (&vr1) && TYPE_OVERFLOW_WRAPS (expr_type)) ... ... extract_range_from_multiplicative_op_1 (vr, code, &vr0, &vr1); but extract_range_from_multiplicative_op_1 also requires range_int_cst_p. I think we should bail out if either range isn't a constant. This might only be theoretical with current sources, but it's needed once polynomial constants are added. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linus-gnu. OK to install? Richard 2017-09-20 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-vrp.c (extract_range_from_binary_expr_1): Don't call extract_range_from_multiplicative_op_1 if !range_int_cst_p. Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c 2017-08-30 12:18:46.631541422 +0100 +++ gcc/tree-vrp.c 2017-09-20 13:04:20.397027078 +0100 @@ -2462,9 +2462,14 @@ extract_range_from_binary_expr_1 (value_ signop sign = TYPE_SIGN (expr_type); unsigned int prec = TYPE_PRECISION (expr_type); - if (range_int_cst_p (&vr0) - && range_int_cst_p (&vr1) - && TYPE_OVERFLOW_WRAPS (expr_type)) + if (!range_int_cst_p (&vr0) + || !range_int_cst_p (&vr1)) + { + set_value_range_to_varying (vr); + return; + } + + if (TYPE_OVERFLOW_WRAPS (expr_type)) { typedef FIXED_WIDE_INT (WIDE_INT_MAX_PRECISION * 2) vrp_int; typedef generic_wide_int