From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7221B3853D7A for ; Thu, 17 Nov 2022 19:37:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7221B3853D7A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668713855; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=ttkL60lH/+Zs+b/QHT7BuWh+VMMJdYz9SFPtSkdVc5s=; b=QqvoHejb8WhcX8SHrQycQcGXHClm42+55ZQiWp0nUulnZjKXhyhmKAfxuVxNXsJSFXpGRM l2vJlUEeD+h0Ojbhvjl3DBnv82qCi7vXDoZE0l1Uz2vwPaBVRoXhaJQckgLA/tPP1eSkyg h7xexO+bg0RrPY9/OtPwZDxWceIPDTM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-PJiiPL8WOgi2EZYERIv-_g-1; Thu, 17 Nov 2022 14:37:31 -0500 X-MC-Unique: PJiiPL8WOgi2EZYERIv-_g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56396882823; Thu, 17 Nov 2022 19:37:31 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 169051415119; Thu, 17 Nov 2022 19:37:30 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2AHJbQN3014251 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 17 Nov 2022 20:37:26 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2AHJbOYB014250; Thu, 17 Nov 2022 20:37:24 +0100 Date: Thu, 17 Nov 2022 20:37:24 +0100 From: Jakub Jelinek To: Joseph Myers Cc: Aldy Hernandez , GCC patches , Andrew MacLeod Subject: Re: [PATCH] [range-ops] Implement sqrt. Message-ID: Reply-To: Jakub Jelinek References: <20221113200553.440728-1-aldyh@redhat.com> <6150f7fd-5a57-c138-f65e-8dc3bf13d11a@codesourcery.com> <4441fc8a-e9e1-6fdd-20d1-473d10122426@codesourcery.com> MIME-Version: 1.0 In-Reply-To: <4441fc8a-e9e1-6fdd-20d1-473d10122426@codesourcery.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham 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, Nov 17, 2022 at 06:59:45PM +0000, Joseph Myers wrote: > On Thu, 17 Nov 2022, Aldy Hernandez via Gcc-patches wrote: > > > So... is the optimization wrong? Are we not allowed to substitute > > that NAN if we know it's gonna happen? Should we also allow F F F F F > > in the test? Or something else? > > This seems like the usual ambiguity about what transformations > -ftrapping-math (on by default) is meant to prevent. > > Generally it's understood to prevent transformations that add *or remove* > exceptions, so folding a case that raises "invalid" to a NaN (with > "invalid" no longer raised) is invalid with -ftrapping-math. But that > doesn't tend to be applied if the operation raising the exceptions has a > result that is otherwise unused - in such a case the operation may still > be removed completely (the exception isn't properly treated as a side > effect to avoid dead code elimination; cf. Marc Glisse's -ffenv-access > patches from August 2020). And it may often also not be applied to > "inexact". The problem is that the above model I'm afraid is largely incompatible with the optimizations ranger provides. A strict model where no operations that could raise exceptions are discarded is easy, we let frange optimize as much as it wants and just tell DCE not to eliminate operations that can raise exceptions. But in the model where some exceptions can be discarded if results are unused but not others where they are used, there is no way to distinguish between the result of the operation really isn't needed and ranger figured out a result (or usable range of something) and therefore the result of the operation isn't needed. Making frange more limited with -ftrapping-math, making it punt for operations that could raise an exception would be quite drastic pessimization. Perhaps for -ftrapping-math we could say no frange value is singleton and so at least for most of operations we actually wouldn't optimize out the whole computation when we know the result? Still, we could also just have r = long_computation (x, y, z); if (r > 42.0) and if frange figures out that r must be [256.0, 1024.0] and never NAN, we'd still happily optimize away the comparison. Jakub