From patchwork Tue May 9 08:48:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 759973 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wMY2J6W4wz9s3T for ; Tue, 9 May 2017 18:49:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="pZqEJlR7"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=jjMvbe4Wd15EHD/6FcBXyFvHVJwVhYEfI7BTMRpkVV1us4OpKWlhF 8XPmCXlSde/EloNr0qn1BXx2/xYlgThdJG3M1SNHuoA5vICaFfEMjiHsta5XMfyw OP4J8LD8NOdOIRCoBdRjb/83NpgpP8P/olabinEHwshHd00m+T++WA= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=gVtBXzvEzUy5ExfaPNmC5r0ya54=; b=pZqEJlR76Fskd5faoF4R zVVfZf9CWth/XP/oOt/vpz21mtD4ESU9iYRdHp/cjYbz0/FG8MZiRDpuh60h1rFf j2PtMhQ2HwDqMjMMRFSYCu1MoEb+96755JiMJthEqzV74M+KaVNG1Iyd1LrcAxxt vEfWDIdII9LK9b4blImlQhE= Received: (qmail 59074 invoked by alias); 9 May 2017 08:48:51 -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 56644 invoked by uid 89); 9 May 2017 08:48:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=18511, corner X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 May 2017 08:48:22 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2C047AD25 for ; Tue, 9 May 2017 08:48:17 +0000 (UTC) Date: Tue, 9 May 2017 10:48:17 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] VRP comments cleanup Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 This removes traces of "overflow infinity" from VRP comments and one unreachable case. Bootstrap / regtest running on x86_64-unknown-linux-gnu. Richard. 2017-05-09 Richard Biener * tree-vrp.c (vrp_val_is_max): Adjust comment. (vrp_val_is_min): Likewise. (set_value_range_to_value): Likewise. (set_value_range_to_nonnegative): Likewise. (gimple_assign_nonzero_p): Likewise. (gimple_stmt_nonzero_p): Likewise. (vrp_int_const_binop): Likewise. Remove unreachable case. (adjust_range_with_scev): Adjust comments. (compare_range_with_value): Likewise. (extract_range_from_phi_node): Likewise. (test_for_singularity): Likewise. Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c (revision 247781) +++ gcc/tree-vrp.c (working copy) @@ -185,11 +185,10 @@ vrp_val_min (const_tree type) return TYPE_MIN_VALUE (type); } -/* Return whether VAL is equal to the maximum value of its type. This - will be true for a positive overflow infinity. We can't do a - simple equality comparison with TYPE_MAX_VALUE because C typedefs - and Ada subtypes can produce types whose TYPE_MAX_VALUE is not == - to the integer constant with the same value in the type. */ +/* Return whether VAL is equal to the maximum value of its type. + We can't do a simple equality comparison with TYPE_MAX_VALUE because + C typedefs and Ada subtypes can produce types whose TYPE_MAX_VALUE + is not == to the integer constant with the same value in the type. */ static inline bool vrp_val_is_max (const_tree val) @@ -200,8 +199,7 @@ vrp_val_is_max (const_tree val) && operand_equal_p (val, type_max, 0))); } -/* Return whether VAL is equal to the minimum value of its type. This - will be true for a negative overflow infinity. */ +/* Return whether VAL is equal to the minimum value of its type. */ static inline bool vrp_val_is_min (const_tree val) @@ -412,8 +410,7 @@ copy_value_range (value_range *to, value /* Set value range VR to a single value. This function is only called with values we get from statements, and exists to clear the - TREE_OVERFLOW flag so that we don't think we have an overflow - infinity when we shouldn't. */ + TREE_OVERFLOW flag. */ static inline void set_value_range_to_value (value_range *vr, tree val, bitmap equiv) @@ -424,11 +421,7 @@ set_value_range_to_value (value_range *v set_value_range (vr, VR_RANGE, val, val, equiv); } -/* Set value range VR to a non-negative range of type TYPE. - OVERFLOW_INFINITY indicates whether to use an overflow infinity - rather than TYPE_MAX_VALUE; this should be true if we determine - that the range is nonnegative based on the assumption that signed - overflow does not occur. */ +/* Set value range VR to a non-negative range of type TYPE. */ static inline void set_value_range_to_nonnegative (value_range *vr, tree type) @@ -853,10 +846,7 @@ symbolic_range_based_on_p (value_range * return (min_has_symbol || max_has_symbol); } -/* Return true if the result of assignment STMT is know to be non-zero. - If the return value is based on the assumption that signed overflow is - undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change - *STRICT_OVERFLOW_P.*/ +/* Return true if the result of assignment STMT is know to be non-zero. */ static bool gimple_assign_nonzero_p (gimple *stmt) @@ -888,10 +878,7 @@ gimple_assign_nonzero_p (gimple *stmt) } } -/* Return true if STMT is known to compute a non-zero value. - If the return value is based on the assumption that signed overflow is - undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change - *STRICT_OVERFLOW_P.*/ +/* Return true if STMT is known to compute a non-zero value. */ static bool gimple_stmt_nonzero_p (gimple *stmt) @@ -1610,10 +1597,11 @@ extract_range_from_ssa_name (value_range } -/* Wrapper around int_const_binop. If the operation overflows and we - are not using wrapping arithmetic, then adjust the result to be - -INF or +INF depending on CODE, VAL1 and VAL2. This can return - NULL_TREE for division by zero. */ +/* Wrapper around int_const_binop. If the operation overflows and + overflow is undefined, then adjust the result to be + -INF or +INF depending on CODE, VAL1 and VAL2. Sets *OVERFLOW_P + to whether the operation overflowed. For division by zero + the result is indeterminate but *OVERFLOW_P is set. */ static wide_int vrp_int_const_binop (enum tree_code code, tree val1, tree val2, @@ -1699,9 +1687,8 @@ vrp_int_const_binop (enum tree_code code if (overflow && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (val1))) { - /* If the operation overflowed but neither VAL1 nor VAL2 are - overflown, return -INF or +INF depending on the operation - and the combination of signs of the operands. */ + /* If the operation overflowed return -INF or +INF depending + on the operation and the combination of signs of the operands. */ int sgn1 = tree_int_cst_sgn (val1); int sgn2 = tree_int_cst_sgn (val2); @@ -1727,11 +1714,6 @@ vrp_int_const_binop (enum tree_code code as positive here, for the corner case 0 - (-INF), which overflows, but must yield +INF. */ || (code == MINUS_EXPR && sgn1 >= 0) - /* We only get in here with positive shift count, so the - overflow direction is the same as the sign of val1. - Actually rshift does not overflow at all, but we only - handle the case of shifting overflowed -INF and +INF. */ - || (code == RSHIFT_EXPR && sgn1 >= 0) /* For division, the only case is -INF / -1 = +INF. */ || code == TRUNC_DIV_EXPR || code == FLOOR_DIV_EXPR @@ -4015,11 +3997,6 @@ adjust_range_with_scev (value_range *vr, get_chrec_loop (chrec), true)) return; - /* We use TYPE_MIN_VALUE and TYPE_MAX_VALUE here instead of - negative_overflow_infinity and positive_overflow_infinity, - because we have concluded that the loop probably does not - wrap. */ - type = TREE_TYPE (var); if (POINTER_TYPE_P (type) || !TYPE_MIN_VALUE (type)) tmin = lower_bound_in_type (type, type); @@ -4164,8 +4141,8 @@ adjust_range_with_scev (value_range *vr, - Return NULL_TREE if it is not always possible to determine the value of the comparison. - Also set *STRICT_OVERFLOW_P to indicate whether a range with an - overflow infinity was used in the test. */ + Also set *STRICT_OVERFLOW_P to indicate whether comparision evaluation + assumed signed overflow is undefined. */ static tree @@ -4305,8 +4282,8 @@ compare_ranges (enum tree_code comp, val values in VR. Return BOOLEAN_FALSE_NODE if the comparison always returns false. Return NULL_TREE if it is not always possible to determine the value of the comparison. Also set - *STRICT_OVERFLOW_P to indicate whether a range with an overflow - infinity was used in the test. */ + *STRICT_OVERFLOW_P to indicate whether comparision evaluation + assumed signed overflow is undefined. */ static tree compare_range_with_value (enum tree_code comp, value_range *vr, tree val, @@ -7246,7 +7223,7 @@ compare_name_with_value (enum tree_code ranges equivalent to N1 against all the ranges equivalent to N2 to determine the value of N1 COMP N2. Return the same value returned by compare_ranges. Set *STRICT_OVERFLOW_P to indicate - whether we relied on an overflow infinity in the comparison. */ + whether we relied on undefined signed overflow in the comparison. */ static tree @@ -8952,7 +8929,7 @@ extract_range_from_phi_node (gphi *phi, /* To prevent infinite iterations in the algorithm, derive ranges when the new value is slightly bigger or smaller than the previous one. We don't do this if we have seen a new executable - edge; this helps us avoid an overflow infinity for conditionals + edge; this helps us avoid an infinity for conditionals which are not in a loop. If the old value-range was VR_UNDEFINED use the updated range and iterate one more time. If we will not simulate this PHI again via the backedge allow us to iterate. */ @@ -9476,8 +9453,6 @@ test_for_singularity (enum tree_code con written. */ if (cond_code == LE_EXPR || cond_code == LT_EXPR) { - /* This should not be negative infinity; there is no overflow - here. */ min = TYPE_MIN_VALUE (TREE_TYPE (op0)); max = op1; @@ -9492,8 +9467,6 @@ test_for_singularity (enum tree_code con } else if (cond_code == GE_EXPR || cond_code == GT_EXPR) { - /* This should not be positive infinity; there is no overflow - here. */ max = TYPE_MAX_VALUE (TREE_TYPE (op0)); min = op1;