From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 4E8FF383FB86; Mon, 5 Sep 2022 20:16:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E8FF383FB86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662408996; bh=cKegyI9F/UEsKNDc9NyrW+vKGL0BikYkQ9TcmhVN1mA=; h=From:To:Subject:Date:From; b=F5QGIs9xAIwgrTJXMxkGGG7dtvRJh5GQ2Dt9KyIYADhi5mFvnexd0N9NlFdrMQEsD e5NCMaB/JxgwcyTWfCeFrsvM8gIHqNCFbBclH8XyeyBz/PuOEtw3KcxUXMJkuQYNBO cv7Q5/8DlvdS/ATMxhRKytdNu5oERWZIt4A6+/mk= 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-2450] Do not fold __builtin_signbit if NAN is a possibility. X-Act-Checkin: gcc X-Git-Author: Aldy Hernandez X-Git-Refname: refs/heads/master X-Git-Oldrev: 1de9aa45529a98a5760a21570b181b78dbd11b3c X-Git-Newrev: 5f895f22173d78c1995a001d721d2ae1d075797b Message-Id: <20220905201636.4E8FF383FB86@sourceware.org> Date: Mon, 5 Sep 2022 20:16:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5f895f22173d78c1995a001d721d2ae1d075797b commit r13-2450-g5f895f22173d78c1995a001d721d2ae1d075797b Author: Aldy Hernandez Date: Mon Sep 5 20:06:30 2022 +0200 Do not fold __builtin_signbit if NAN is a possibility. I had some queued up work to try harder to keep the sign bit up to date in the presence of NANs, but after the discussion with Richi regarding the representation of NAN and signs in the frange, I've decided to put it aside until after Cauldron, since it'll probably get rewritten anyhow. So for now, the sign property in the frange is not applicable to NANs. Right now the only user of the sign bit that affects generated code (apart from signed zeros) is __builtin_sign, so I'm just checking for NAN there. Signed zeros continue working as before. Regstrapped and mpfr checked on x86-64 Linux. gcc/ChangeLog: * gimple-range-fold.cc (fold_using_range::range_of_builtin_int_call): Ignore sign bit when there's the possibility of a NAN. Diff: --- gcc/gimple-range-fold.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 3543f0980b8..c9c7a2ccc70 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -1029,7 +1029,9 @@ fold_using_range::range_of_builtin_int_call (irange &r, gcall *call, frange tmp; if (src.get_operand (tmp, arg)) { - if (tmp.get_signbit ().varying_p ()) + if (tmp.get_signbit ().varying_p () + // FIXME: We don't support signed NANs yet. + || !tmp.get_nan ().no_p ()) return false; if (tmp.get_signbit ().yes_p ()) r.set_nonzero (type);