From patchwork Fri Sep 14 10:25:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 969718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-485641-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Vl+UMFEm"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42BWrD6vcXz9s9h for ; Fri, 14 Sep 2018 20:25:47 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=gRxCPQ5MANFFKGflWf/lQ7y99U+R6OkIrWobO71Tbx4jyZyUfe s0xSPPhoEnIs7DH54IYfy5JvI52VQ8W3CPgQIVke0YA8FmOgM2hmCKaw9xfo5yhX hlJFr5cx5w59vADcAVnf9UYkeCXl7nZvI2gEsfhT99dWebjmQrQ6DEs/g= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=chWzxhdGBljpPkRI+4/zd9nQ5B0=; b=Vl+UMFEmMdvVucNa1jZi WcdKYzq9eg4FqCSeeBApO0gmnaCho237OyWkaY0I5dQwR3i/81FZSlfqI+q+U8SS jzuI8J2782MF4Gzp/q6GnRKf8LZYSthS+AoNFSWMUu/rNh7hipDyc6+PNAnx3IWt JgbEteMgJCVUZA2V29hm+zU= Received: (qmail 66396 invoked by alias); 14 Sep 2018 10:25:40 -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 66264 invoked by uid 89); 14 Sep 2018 10:25:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=limits, gt_p X-HELO: mail-wr1-f49.google.com Received: from mail-wr1-f49.google.com (HELO mail-wr1-f49.google.com) (209.85.221.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Sep 2018 10:25:25 +0000 Received: by mail-wr1-f49.google.com with SMTP id v16-v6so9957663wro.11 for ; Fri, 14 Sep 2018 03:25:25 -0700 (PDT) Received: from abulafia.quesejoda.com (247.red-79-147-188.dynamicip.rima-tde.net. [79.147.188.247]) by smtp.gmail.com with ESMTPSA id u40-v6sm11182012wrc.43.2018.09.14.03.25.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 03:25:22 -0700 (PDT) To: gcc-patches From: Aldy Hernandez Subject: VRP: make worst case scenario for ABS_EXPR is still the set of positives Message-ID: <9793f823-aa0a-594a-6689-1dad6722dd7c@redhat.com> Date: Fri, 14 Sep 2018 06:25:21 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-IsSubscribed: yes First, there's no sense handling !VR_RANGE and symbolics now that we've normalized the inputs. Second, even if we wrap around while calculating ABS, we at the least know the result is positive ;-). BTW, we've already handled ABS(-MIN) and -frapv by the time we get here, so we know we won't get nonsensical input. OK? commit 6e874be13a0bd53811e095328c1d175723f11f84 Author: Aldy Hernandez Date: Fri Sep 14 00:03:04 2018 +0200 * tree-vrp.c (extract_range_from_unary_expr): Do not special case symbolics or VR_VARYING ranges for ABS_EXPR. * wide-int-range.cc (wide_int_range_abs): Return positive numbers when range will wrap. diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 1adb919a6df..622ccbc2df7 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1894,11 +1894,6 @@ extract_range_from_unary_expr (value_range *vr, } else if (code == ABS_EXPR) { - if (vr0.type != VR_RANGE || symbolic_range_p (&vr0)) - { - set_value_range_to_varying (vr); - return; - } wide_int wmin, wmax; wide_int vr0_min, vr0_max; extract_range_into_wide_ints (&vr0, sign, prec, vr0_min, vr0_max); diff --git a/gcc/wide-int-range.cc b/gcc/wide-int-range.cc index 8a3dfd25684..a85fe9f9ad7 100644 --- a/gcc/wide-int-range.cc +++ b/gcc/wide-int-range.cc @@ -728,10 +728,13 @@ wide_int_range_abs (wide_int &min, wide_int &max, } /* If the new range has its limits swapped around (MIN > MAX), then - the operation caused one of them to wrap around, mark the new - range VARYING. */ + the operation caused one of them to wrap around. The only thing + we know is that the result is positive. */ if (wi::gt_p (min, max, sign)) - return false; + { + min = wi::zero (prec); + max = max_value; + } return true; }