From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 628823858D37; Thu, 1 Sep 2022 16:22:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 628823858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.93,281,1654588800"; d="scan'208";a="82190043" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 01 Sep 2022 08:22:21 -0800 IronPort-SDR: LM10m/mOC+CsqImkAibhCFG6nz7UvzLilT3kdolfv3fDRZD0sr4DV2HojwG3PsmXwm6ZZTHnDT GkRJN6pF6ZLNAnAjzRFsflJuugKRzqGelDa5rvxc89NoIl2/iuZUeauHAr3aUhkJekIQ+gaA4M Apu55lQTw29WkfGNBNrv4dzIf+sBeYLJnTQOR8yTuhOtOcLa0m/QSiv871X0MOfaabc1Wg1Asl jdbDkb5i5OayERarB1ee4EMAMhWh0qkqbmxBk6MafsvgsRbvDwGjurZ3RE1hytIrXVZww4MijN WqY= Date: Thu, 1 Sep 2022 16:22:10 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Marc Glisse via Gcc CC: Marc Glisse , Jakub Jelinek , FX via Fortran , FX Subject: Re: Floating-point comparisons in the middle-end In-Reply-To: Message-ID: References: <8C6DDAA3-A40F-47C7-BE78-D56A3EC70C71@gmail.com> <3BD50DD7-5C9E-42CB-992C-A66584411A4F@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3111.4 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 1 Sep 2022, Marc Glisse via Gcc wrote: > On Thu, 1 Sep 2022, Joseph Myers wrote: > > > On Thu, 1 Sep 2022, FX via Gcc wrote: > > > > > A tentative patch is attached, it seems to work well on simple examples, > > > but for test coverage the hard part is going to be that the comparisons > > > seem to be optimised away very easily into their non-signaling versions. > > > Basically, if I do: > > > > Presumably that can be reproduced without depending on the new built-in > > function? In which case it's an existing bug somewhere in the optimizers. > > (simplify > (cmp @0 REAL_CST@1) > [...] > (if (REAL_VALUE_ISNAN (TREE_REAL_CST (@1)) > && !tree_expr_signaling_nan_p (@1) > && !tree_expr_maybe_signaling_nan_p (@0)) > { constant_boolean_node (cmp == NE_EXPR, type); }) > > only tries to preserve a comparison with sNaN, but not with qNaN. There are So that needs to take more care about what comparison operations are involved. Since such an optimization is fine for quiet comparisons such as ==, != or isless, but not for signaling comparisons such as < <= > >= (subject to any question of splitting up -ftrapping-math into more fine-grained options allowing different transformations). -- Joseph S. Myers joseph@codesourcery.com