From patchwork Wed Sep 20 12:09:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 113105 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp687884qgf; Wed, 20 Sep 2017 05:09:55 -0700 (PDT) X-Received: by 10.84.216.69 with SMTP id f5mr1937493plj.172.1505909395464; Wed, 20 Sep 2017 05:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505909395; cv=none; d=google.com; s=arc-20160816; b=Bj1DCf6KhcEYqzadOOr0EaPZZzKDcehUKR6vwP7e5VIJWvfrQQWJHlekJyzD7Cu/8c 2FpL+Ey6SP8sYNZzXw+ewosjgh88UmRk2BAHgBR33fT5BaZ5erAsYakJN/IgZW0Gm8US jsDHlrHQ3U5zUeqDwFVTDtsUGhnFb6fHA9yTDyWBLd2sS8wk+W77aO/zFLlt9xXUCRmb eeW1SabSBnegy00rY5A4dNybpL1tdrGdRAqUPPmTRXKakAyA42gegZgr3tUyynCRYWmK XSmzN3uZ98DHWnvk/N5uhHZPRrWwSbL9IDKfbJlVlYB/DaxhP5a5vV9zwW6a7N6+fDK9 /jRw== 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=FaB2gFKyfqas71p2A+JZAxPWjyBEiRq3BeCqefyx9Qo=; b=f2RKSjv3Cg2smClrB7BgHaplA0WMmDTcu29Hp8C4MS9CK7eKGPVvv42bsLJvxOzhSI Me3k5k/sumCMZ9IW/QB0cVvaAgVNGBu+45MLRDw1nmIFwhQwzkfWGWiQnb8g06zh3luS ZGZ1sdSidOJQCcKsEUxn7uSVkyvXQTI4l4BaN0rnoH3n5zKXd9PVhfPp/X4w3chM+BbH wrKBtAvLMOXIiv85nCOPH/yEfJQEw7gu3VdiSIjayRePcOb5qqFTTzcbYB7fFPuG3bKF 8eEQVPnJY2c0bZfqgUpC2dbRJ/PHbN7+KDZhcHhfmQmwJ0a2hSIUsMGAPGCMkzeICqgU j9EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yGJbb4Sz; spf=pass (google.com: domain of gcc-patches-return-462577-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462577-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 b3si1213322plb.656.2017.09.20.05.09.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 05:09:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462577-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=yGJbb4Sz; spf=pass (google.com: domain of gcc-patches-return-462577-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462577-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=dwvwmbZS7E0Sj+VSdxpAUTTDxK72PC8AdCw/HGWFO+eG5GvPoiwqd ymFiE2jLaf4u+HlUc9E/vJWTkn3yG/8Dk5s5Pkte3ZpsHevJ2XHXK4ZQJsvffc/y Zf31FZr048JccVZiZHYqPzVDHKOVLbHM9ezefzEfPBQcbKf7gUQTiM= 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=sfDnUYiTtJHYsLNqSDMjTlUpLDM=; b=yGJbb4SzysUkN4vcjyrg aiU0P+dy8Yq6SltxoMutTGAuaUcAaUffHvZcU0qd4I3o5UUJG2EdcanbZKVQZwqo 9rhxFLU93lkh+/47RprnwGiqnRf0+22LZsmWj0wKGuhyMlIDAM18iHyWXHlZjopH SWVGnGxB/17bU+tiZzksj4g= Received: (qmail 43710 invoked by alias); 20 Sep 2017 12:09:42 -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 43698 invoked by uid 89); 20 Sep 2017 12:09:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 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=wi 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; Wed, 20 Sep 2017 12:09:40 +0000 Received: by mail-wm0-f45.google.com with SMTP id i189so6586665wmf.1 for ; Wed, 20 Sep 2017 05:09:39 -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=FaB2gFKyfqas71p2A+JZAxPWjyBEiRq3BeCqefyx9Qo=; b=kwbUKbgCq+Y1EoW7ktFGItQ43YIWtLxvpBwBqHvBqs1WuCpVzbdldjbyopAoWLTE80 HVISMSomznauU2EMWnKx/0tZityo/8R9A2iEe2YnwrS6wDgb80yxkuC7pWy0LF8LrwR7 XiTEmISbobP7uSHtMNZd5Qs3lArpDnr8PWsSwLxj9CPYMqFbFOrzpkDk29HvxYwu67Jo x0qDHZm2sOpH9R27l3FSGC14s2zsHVrGvKQS8eb9EMAJvg/qXls7I6U3bVXr8m6mpgfo rfG9Jz0qc2wPv1IiCHoBgqCy4+f+MIqwo9L8LvtVUTemuE02Jrjaqx/g1w2oFAUUl9+X eq/Q== X-Gm-Message-State: AHPjjUiDYuBAfacz0INC7kZnNs6ODTVaYwzFPbl8MUbn8qndRRX5tnRL CTqQfXhgzjflIxNBmOe/T8TTdACk9tw= X-Google-Smtp-Source: AOwi7QCs95dkzM0p4VjzPfEVvVJOuYuYnt2TCUgK8KBCYtzrSCm+kjRqxqejAEaAOjNN+bbxGzmtbw== X-Received: by 10.28.70.130 with SMTP id t124mr3654358wma.145.1505909377486; Wed, 20 Sep 2017 05:09:37 -0700 (PDT) Received: from localhost (92.40.248.127.threembb.co.uk. [92.40.248.127]) by smtp.gmail.com with ESMTPSA id j6sm583279wmg.28.2017.09.20.05.09.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Sep 2017 05:09:36 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Add missing int_cst_rangeN checks to tree-vrp.c Date: Wed, 20 Sep 2017 13:09:34 +0100 Message-ID: <87r2v11sht.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The BIT_AND_EXPR handling in extract_range_from_binary_expr_1 was using value_range_constant_singleton without first checking whether the range was a constant. The earlier handling was correctly guarded: /* If either input range contains only non-negative values we can truncate the result range maximum to the respective maximum of the input range. */ if (int_cst_range0 && tree_int_cst_sgn (vr0.min) >= 0) wmax = wi::min (wmax, vr0.max, TYPE_SIGN (expr_type)); if (int_cst_range1 && tree_int_cst_sgn (vr1.min) >= 0) wmax = wi::min (wmax, vr1.max, TYPE_SIGN (expr_type)); so this patch uses the same guards again. Existing tests showed the need for this 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): Check int_cst_rangeN before calling value_range_constant_singleton (&vrN). Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c 2017-09-20 13:04:29.932873038 +0100 +++ gcc/tree-vrp.c 2017-09-20 13:07:32.589667751 +0100 @@ -2930,9 +2930,11 @@ extract_range_from_binary_expr_1 (value_ = wi::set_bit_in_zero (TYPE_PRECISION (expr_type) - 1, TYPE_PRECISION (expr_type)); if (!TYPE_UNSIGNED (expr_type) - && ((value_range_constant_singleton (&vr0) + && ((int_cst_range0 + && value_range_constant_singleton (&vr0) && !wi::cmps (vr0.min, sign_bit)) - || (value_range_constant_singleton (&vr1) + || (int_cst_range1 + && value_range_constant_singleton (&vr1) && !wi::cmps (vr1.min, sign_bit)))) { min = TYPE_MIN_VALUE (expr_type);