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.129.124]) by sourceware.org (Postfix) with ESMTPS id 1A133383578F for ; Mon, 14 Nov 2022 07:45:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1A133383578F 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=1668411941; h=from:from: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=sMaYb+YHwcthjoums94fEgGP+Y3cveHBp2uPPxOtiUo=; b=b/IuuPAOh6IgosHJbcxDpqTvFMi6Tkx7w328MrDdQ2WFT510O1b3skvH+lJAsyReA28dri 6Cc6B6cqER1LAOYJehCTvL8dqCyIJbI3YfoiCGheHDevV/CqBUgfw4mHQmeY2tHYcYn9QJ HSNnF95eyCQFCftlR0alVb5U43U0+/k= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-63-dzpomeqyOcqJyqYQiGjPiw-1; Mon, 14 Nov 2022 02:45:39 -0500 X-MC-Unique: dzpomeqyOcqJyqYQiGjPiw-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-370624ca2e8so99608187b3.16 for ; Sun, 13 Nov 2022 23:45:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sMaYb+YHwcthjoums94fEgGP+Y3cveHBp2uPPxOtiUo=; b=QlabtM9ZXxsvsWHT0ZafQsJMBW6jqFXl9/wj51ecUJ+T4F+HEjRXHJldkPZ40fqvgZ 0Z5Omka7b4DtrJRrWrVpXSd3Y2vCoRvu6559EjxeakjmTu3DVcjlXc6pwe9xGPuEElg4 KZX1sKmqANsiMAUR7JDEspgLRbu6fvvNm7zDxMPu1rempkH6gcfeK51FmL09pMXR+jkB d0hmzw05Tp5Ytd4WLjhnKwdiMSrBODj7xvQoi32dtCO30lpgxoUjCUuQ1ezvVRUdGbUs Io4NAWdFUP3Xky3UOSVJaOZRZC6srp9QGOj0C+b6ci7cEtRrru+GzNjeFAMjKHnMMKug ijFw== X-Gm-Message-State: ANoB5plbuTuXjGc1rPTIvqd8D4PM21NGygrVnoMjLs0zbVcunjvOcDsH NbL3plNLIpGcijmxT3BoDlqjMqlBFHNoO66QS8483yuaEy2GGBV1nlgymCCKJ6gnnBIGjmVqCa5 7/RvCxZmHgGzBMnVR60Mgnh/IR9VCb3Ql9g== X-Received: by 2002:a25:c6c1:0:b0:6b3:369f:7436 with SMTP id k184-20020a25c6c1000000b006b3369f7436mr11661962ybf.172.1668411939320; Sun, 13 Nov 2022 23:45:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf6p7+CosIzL+BWNVPJoqESgeugG64bO2ZWWnLv/1ojGVManot1wDU3I4L6MQwV/c0xx5rN/+1bjoU4hFIwxhEo= X-Received: by 2002:a25:c6c1:0:b0:6b3:369f:7436 with SMTP id k184-20020a25c6c1000000b006b3369f7436mr11661957ybf.172.1668411939086; Sun, 13 Nov 2022 23:45:39 -0800 (PST) MIME-Version: 1.0 References: <20221113200553.440728-1-aldyh@redhat.com> In-Reply-To: From: Aldy Hernandez Date: Mon, 14 Nov 2022 08:45:28 +0100 Message-ID: Subject: Re: [PATCH] [range-ops] Implement sqrt. To: Jakub Jelinek Cc: "Joseph S. Myers" , GCC patches , Andrew MacLeod X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-5.8 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 Sun, Nov 13, 2022 at 9:39 PM Jakub Jelinek wrote: > > On Sun, Nov 13, 2022 at 09:05:53PM +0100, Aldy Hernandez wrote: > > It seems SQRT is relatively straightforward, and it's something Jakub > > wanted for this release. > > > > Jakub, what do you think? > > > > p.s. Too tired to think about op1_range. > > That would be multiplication of the same value twice, i.e. > fop_mult with trio that has op1_op2 () == VREL_EQ? > But see below, as sqrt won't be always precise, we need to account for > some errors. > > > gcc/ChangeLog: > > > > * gimple-range-op.cc (class cfn_sqrt): New. > > (gimple_range_op_handler::maybe_builtin_call): Add cases for sqrt. > > Yes, I'd like to see SQRT support in. > The only thing I'm worried is that unlike {+,-,*,/}, negation etc. typically > implemented in hardware or precise soft-float, sqrt is often implemented > in library using multiple floating point arithmetic functions. And different > implementations have different accuracy. > > So, I wonder if we don't need to add a target hook where targets will be > able to provide upper bound on error for floating point functions for > different floating point modes and some way to signal unknown accuracy/can't > be trusted, in which case we would give up or return just the range for > VARYING. > Then, we could write some tests that say in a loop constructs random > floating point values (perhaps sanitized to be non-NAN), calls libm function > and the same mpfr one and return maximum error in ulps. > And then record those, initially for glibc and most common targets and > gradually maintainers could supply more. > > If we add an infrastructure for that within a few days, then we could start > filling the details. One would hope that sqrt has < 10ulps accuracy if not > already the 0.5ulp one, but for various other functions I think it can be I don't know what would possess me to think that sqrt would be easy ;-). Sure, I can sink a few days to flesh this out if you're willing to review it. Aldy