From patchwork Fri Oct 4 07:08:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1171592 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-510208-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="gKde/9+l"; 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 46l1FG0XDWz9sPq for ; Fri, 4 Oct 2019 17:08: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:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Hl8Ci+bIIb495BeIC/CtQ97STbpS3QkjLyG/mYFEA5X6gFSLpE aP5ggmQT+fF69EdOvDJspqTyHCklEg16XA4SaJzFivHcIKR35I5/YdOu6GVA1PVd Iz03ioLfSWPS/fzvABZNU9Sj+hT89lxPPbadFm4wF+xJKPA/6Q47j0xJA= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=b9d85Vm8FjJ0tA33alMKxoKkvoA=; b=gKde/9+lLmeBOLF+FRTz di/bo5hc+dX7ot/Up506Uv2eaqNb7USYLzFxSqXUyQvvX3LDgXpO+yt6qnxeiIbt WZYfnepGEe2e3ow9TlImEsJTSIEKsrPJvh6EDMZP8ZNnbopAOgU1IrgnPGzuHmTp 6d1pEb18Cg/hsOBFwYDWw98= Received: (qmail 84168 invoked by alias); 4 Oct 2019 07:08: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 84158 invoked by uid 89); 4 Oct 2019 07:08:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=vr_varying, rangeops, VR_VARYING, sk:value_r X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 Oct 2019 07:08:38 +0000 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1199A81129 for ; Fri, 4 Oct 2019 07:08:37 +0000 (UTC) Received: by mail-wr1-f69.google.com with SMTP id f3so2264485wrr.23 for ; Fri, 04 Oct 2019 00:08:37 -0700 (PDT) Received: from abulafia.quesejoda.com (136.red-2-139-5.dynamicip.rima-tde.net. [2.139.5.136]) by smtp.gmail.com with ESMTPSA id r10sm4042029wml.46.2019.10.04.00.08.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Oct 2019 00:08:33 -0700 (PDT) To: gcc-patches Cc: Andrew MacLeod From: Aldy Hernandez Subject: committed: cleanups to range-op.cc Message-ID: Date: Fri, 4 Oct 2019 03:08:31 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 X-IsSubscribed: yes I've renamed some of the function names in range-ops we've been dragging around to something more sensible. I've also adjusted the comments, which were a bit dated. Committed as obvious. commit 9734aa22a81bf5a5f7c38631df67005ece63894b Author: Aldy Hernandez Date: Thu Oct 3 10:43:44 2019 +0200 Adjust various comments and rename some functions in range-op.cc to improve readability. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0c8f331988f..6e4f145af46 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2019-10-04 Aldy Hernandez + + (value_range_from_overflowed_bounds): Rename from + adjust_overflow_bound. + (value_range_with_overflow): Rename from + create_range_with_overflow. + (create_possibly_reversed_range): Adjusted for above renames. + (operator_*::wi_fold): Same. + (cross_product_operator::wi_cross_productor): Same. + 2019-10-04 Bernd Edlinger * doc/invoke.texi (-Wshadow=global, -Wshadow=local, diff --git a/gcc/range-op.cc b/gcc/range-op.cc index b538b00459a..fff4a55f88d 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -185,12 +185,13 @@ range_operator::op2_range (value_range_base &r ATTRIBUTE_UNUSED, } -// Called when there is either an overflow OR an underflow... which -// means an anti range must be created to compensate. This does not -// cover the case where there are 2 possible overflows, or none. +// Create and return a range from a pair of wide-ints that are known +// to have overflowed (or underflowed). static value_range_base -adjust_overflow_bound (tree type, const wide_int &wmin, const wide_int &wmax) +value_range_from_overflowed_bounds (tree type, + const wide_int &wmin, + const wide_int &wmax) { const signop sgn = TYPE_SIGN (type); const unsigned int prec = TYPE_PRECISION (type); @@ -216,15 +217,15 @@ adjust_overflow_bound (tree type, const wide_int &wmin, const wide_int &wmax) return value_range_base (VR_ANTI_RANGE, type, tmin, tmax); } -// Given a newly calculated lbound and ubound, examine their -// respective overflow bits to determine how to create a range. -// Return said range. +// Create and return a range from a pair of wide-ints. MIN_OVF and +// MAX_OVF describe any overflow that might have occurred while +// calculating WMIN and WMAX respectively. static value_range_base -create_range_with_overflow (tree type, - const wide_int &wmin, const wide_int &wmax, - wi::overflow_type min_ovf = wi::OVF_NONE, - wi::overflow_type max_ovf = wi::OVF_NONE) +value_range_with_overflow (tree type, + const wide_int &wmin, const wide_int &wmax, + wi::overflow_type min_ovf = wi::OVF_NONE, + wi::overflow_type max_ovf = wi::OVF_NONE) { const signop sgn = TYPE_SIGN (type); const unsigned int prec = TYPE_PRECISION (type); @@ -255,7 +256,7 @@ create_range_with_overflow (tree type, if ((min_ovf == wi::OVF_UNDERFLOW && max_ovf == wi::OVF_NONE) || (max_ovf == wi::OVF_OVERFLOW && min_ovf == wi::OVF_NONE)) - return adjust_overflow_bound (type, wmin, wmax); + return value_range_from_overflowed_bounds (type, wmin, wmax); // Other underflow and/or overflow, drop to VR_VARYING. return value_range_base (type); @@ -282,9 +283,9 @@ create_range_with_overflow (tree type, } } -// Like above, but canonicalize the case where the bounds are swapped -// and overflow may wrap. In which case, we transform [10,5] into -// [MIN,5][10,MAX]. +// Create and return a range from a pair of wide-ints. Canonicalize +// the case where the bounds are swapped. In which case, we transform +// [10,5] into [MIN,5][10,MAX]. static inline value_range_base create_possibly_reversed_range (tree type, @@ -293,7 +294,7 @@ create_possibly_reversed_range (tree type, signop s = TYPE_SIGN (type); // If the bounds are swapped, treat the result as if an overflow occured. if (wi::gt_p (new_lb, new_ub, s)) - return adjust_overflow_bound (type, new_lb, new_ub); + return value_range_from_overflowed_bounds (type, new_lb, new_ub); // Otherwise its just a normal range. return value_range_base (type, new_lb, new_ub); @@ -907,7 +908,7 @@ operator_plus::wi_fold (tree type, signop s = TYPE_SIGN (type); wide_int new_lb = wi::add (lh_lb, rh_lb, s, &ov_lb); wide_int new_ub = wi::add (lh_ub, rh_ub, s, &ov_ub); - return create_range_with_overflow (type, new_lb, new_ub, ov_lb, ov_ub); + return value_range_with_overflow (type, new_lb, new_ub, ov_lb, ov_ub); } bool @@ -954,7 +955,7 @@ operator_minus::wi_fold (tree type, signop s = TYPE_SIGN (type); wide_int new_lb = wi::sub (lh_lb, rh_ub, s, &ov_lb); wide_int new_ub = wi::sub (lh_ub, rh_lb, s, &ov_ub); - return create_range_with_overflow (type, new_lb, new_ub, ov_lb, ov_ub); + return value_range_with_overflow (type, new_lb, new_ub, ov_lb, ov_ub); } bool @@ -994,7 +995,7 @@ operator_min::wi_fold (tree type, signop s = TYPE_SIGN (type); wide_int new_lb = wi::min (lh_lb, rh_lb, s); wide_int new_ub = wi::min (lh_ub, rh_ub, s); - return create_range_with_overflow (type, new_lb, new_ub); + return value_range_with_overflow (type, new_lb, new_ub); } @@ -1016,7 +1017,7 @@ operator_max::wi_fold (tree type, signop s = TYPE_SIGN (type); wide_int new_lb = wi::max (lh_lb, rh_lb, s); wide_int new_ub = wi::max (lh_ub, rh_ub, s); - return create_range_with_overflow (type, new_lb, new_ub); + return value_range_with_overflow (type, new_lb, new_ub); } @@ -1087,7 +1088,7 @@ cross_product_operator::wi_cross_product (tree type, // Choose min and max from the ordered pairs. wide_int res_lb = wi::min (cp1, cp3, sign); wide_int res_ub = wi::max (cp2, cp4, sign); - return create_range_with_overflow (type, res_lb, res_ub); + return value_range_with_overflow (type, res_lb, res_ub); } @@ -1832,7 +1833,7 @@ wi_optimize_and_or (value_range_base &r, } else gcc_unreachable (); - r = create_range_with_overflow (type, res_lb, res_ub); + r = value_range_with_overflow (type, res_lb, res_ub); return true; } @@ -1932,7 +1933,7 @@ operator_bitwise_and::wi_fold (tree type, if (wi::gt_p (new_lb, new_ub,sign)) return value_range_base (type); - return create_range_with_overflow (type, new_lb, new_ub); + return value_range_with_overflow (type, new_lb, new_ub); } bool @@ -2070,7 +2071,7 @@ operator_bitwise_or::wi_fold (tree type, if (wi::gt_p (new_lb, new_ub,sign)) return value_range_base (type); - return create_range_with_overflow (type, new_lb, new_ub); + return value_range_with_overflow (type, new_lb, new_ub); } bool @@ -2132,7 +2133,7 @@ operator_bitwise_xor::wi_fold (tree type, // If the range has all positive or all negative values, the result // is better than VARYING. if (wi::lt_p (new_lb, 0, sign) || wi::ge_p (new_ub, 0, sign)) - return create_range_with_overflow (type, new_lb, new_ub); + return value_range_with_overflow (type, new_lb, new_ub); return value_range_base (type); } @@ -2186,7 +2187,7 @@ operator_trunc_mod::wi_fold (tree type, tmp = wi::zero (prec); new_ub = wi::min (new_ub, tmp, sign); - return create_range_with_overflow (type, new_lb, new_ub); + return value_range_with_overflow (type, new_lb, new_ub); }