From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 3E4C63858D1E; Thu, 10 Nov 2022 15:41:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E4C63858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668094898; bh=He9AZDUSQjJVpN/LEZ5zq1j7xSwh27LOvGQ3qR72H6c=; h=From:To:Subject:Date:From; b=dcpytypovPJOi6OfnVFSe3K5jlfr+swOfSVbrVQpkzIeqtw7G5Rxq1ROoVAi2HS5E j6HFoaZT/50hdgmHGmYX8tCRdXbkSYs+qw1SCW3KFS39OySIKEoYxKxGNqAE+CYpgn yc0CzEDZIIX40OyXBZXvBtcvMyyb7QOaJa+5/0nk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3880] Do not specify NAN sign in frange::set_nonnegative. X-Act-Checkin: gcc X-Git-Author: Aldy Hernandez X-Git-Refname: refs/heads/master X-Git-Oldrev: f1b76811f2c3773e8cabcc07932bf13e82e264db X-Git-Newrev: b4fc06d8c9091166a7404ca1dbeb7c197263de94 Message-Id: <20221110154138.3E4C63858D1E@sourceware.org> Date: Thu, 10 Nov 2022 15:41:38 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b4fc06d8c9091166a7404ca1dbeb7c197263de94 commit r13-3880-gb4fc06d8c9091166a7404ca1dbeb7c197263de94 Author: Aldy Hernandez Date: Thu Nov 10 14:29:13 2022 +0100 Do not specify NAN sign in frange::set_nonnegative. After further reading of the IEEE 754 standard, it has become clear that there are no guarantees with regards to the sign of a NAN when it comes to any operation other than copy, copysign, abs, and negate. Currently, set_nonnegative() is only used in one place in ranger applicable to floating point values, when expanding unknown calls. Since we already specially handle copy, copysign, abs, and negate, all the calls to set_nonnegative() must be NAN-sign agnostic. The cleanest solution is to leave the sign unspecificied in frange::set_nonnegative(). Any special case, must be handled by the caller. gcc/ChangeLog: * value-range.cc (frange::set_nonnegative): Remove NAN sign handling. (range_tests_signed_zeros): Adjust test. Diff: --- gcc/value-range.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 852ac09f2c4..d55d85846c1 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -797,14 +797,17 @@ frange::zero_p () const && real_iszero (&m_max)); } +// Set the range to non-negative numbers, that is [+0.0, +INF]. +// +// The NAN in the resulting range (if HONOR_NANS) has a varying sign +// as there are no guarantees in IEEE 754 wrt to the sign of a NAN, +// except for copy, abs, and copysign. It is the responsibility of +// the caller to set the NAN's sign if desired. + void frange::set_nonnegative (tree type) { set (type, dconst0, frange_val_max (type)); - - // Set +NAN as the only possibility. - if (HONOR_NANS (type)) - update_nan (/*sign=*/false); } // Here we copy between any two irange's. The ranges can be legacy or @@ -3923,7 +3926,6 @@ range_tests_signed_zeros () ASSERT_TRUE (r0.undefined_p ()); r0.set_nonnegative (float_type_node); - ASSERT_TRUE (r0.signbit_p (signbit) && !signbit); if (HONOR_NANS (float_type_node)) ASSERT_TRUE (r0.maybe_isnan ()); }