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 D15F13858D1E for ; Tue, 25 Apr 2023 08:59:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D15F13858D1E 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=1682413173; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yxfN6rbZHrnL9pnK99id8SjMW6Ge/Dtw8KdJ30DMocU=; b=e7xfy+HQqEKhlq8tGWbH+0qP+zrYh01JXr1JNw5O1njunQHdTven/mziikmpibYnNVIpyL kevkzMHoJfh3JEhl7McLrm9GHdWvww7klKCO9eRNTEy/5ehB9ARYmHamxgzLHz1qReWE4q JJPbjmEq2uW2hIFVXc00rIiKlO5Hu00= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-550-ZCR9PiazOxybLP24FU7ilg-1; Tue, 25 Apr 2023 04:59:31 -0400 X-MC-Unique: ZCR9PiazOxybLP24FU7ilg-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-2ff4bc7a6a3so3154552f8f.3 for ; Tue, 25 Apr 2023 01:59:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682413170; x=1685005170; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yxfN6rbZHrnL9pnK99id8SjMW6Ge/Dtw8KdJ30DMocU=; b=GVs2m43OEI4ZLby36PIEnNZ4iknOmOay341B9wCoefzr1FDJ24eRVYDdGKxb2lBFAf D/gjF/zUftent3i5Un01Z5DGVx6tL/3NKkqYCn8x0Yn5d13N7UUtQexc588KCFci+fa3 h42K+5RtfAJFC63vfMQM8rRF+R0lsulg5zXIetE+cNh77BpzOYEbS5OzP6t7C3zh0km4 EeEKlUNSB7D472Wzz52OM6WBHD+kisghiql2AEXQscpEAk8yf0SJUny4thVd4+R1zYuI Z1eh0knThXbbnP2MFP0Rh3amJy6ypvHgCu/bdVANBoaCw0VzenOejqqFlu6j6ft8318Q bOyQ== X-Gm-Message-State: AAQBX9d4IyrqDjvnCsWlJzDPzgo/imyqSkPKla+7eiPSM7OMoNoDo0FC ZQkUTc2lwM+5YlGdLoYsmcpIFk5N4wJyE/CBFo04zfNCaaNMHqsbsFX3b7fpCYIRoO/IS6JW17c eaPGF5+JfOM8tEo3dA0VPRkvZkg== X-Received: by 2002:a05:6000:11cf:b0:2f6:c7af:945c with SMTP id i15-20020a05600011cf00b002f6c7af945cmr9430948wrx.31.1682413169854; Tue, 25 Apr 2023 01:59:29 -0700 (PDT) X-Google-Smtp-Source: AKy350YCJ/pStxRIl26QVq23P7n1bHspG417RoV/a/INePQIUk3TBdbRU2YZZ3ckwRizjRNsqdmJtg== X-Received: by 2002:a05:6000:11cf:b0:2f6:c7af:945c with SMTP id i15-20020a05600011cf00b002f6c7af945cmr9430928wrx.31.1682413169449; Tue, 25 Apr 2023 01:59:29 -0700 (PDT) Received: from [192.168.1.201] ([139.47.42.170]) by smtp.gmail.com with ESMTPSA id m7-20020adfe0c7000000b003048477729asm2458466wri.81.2023.04.25.01.59.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Apr 2023 01:59:29 -0700 (PDT) Message-ID: Date: Tue, 25 Apr 2023 10:59:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] Implement range-op entry for sin/cos. To: Jakub Jelinek , Siddhesh Poyarekar Cc: "Joseph S. Myers" , GCC patches , Andrew MacLeod References: <20230418131250.310916-1-aldyh@redhat.com> <64abfdef-8eae-9ce9-af62-c57c14c9ffbb@gotplt.org> From: Aldy Hernandez In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 4/21/23 08:52, Jakub Jelinek wrote: > On Thu, Apr 20, 2023 at 09:14:10PM -0400, Siddhesh Poyarekar wrote: >> On 2023-04-20 13:57, Siddhesh Poyarekar wrote: >>> For bounds that aren't representable, one could get error bounds from >>> libm-test-ulps data in glibc, although I reckon those won't be >>> exhaustive.  From a quick peek at the sin/cos data, the arc target seems >>> to be among the worst performers at about 7ulps, although if you include >>> the complex routines we get close to 13 ulps.  The very worst >>> imprecision among all math routines (that's gamma) is at 16 ulps for >>> power in glibc tests, so maybe allowing about 25-30 ulps error in bounds >>> might work across the board. >> >> I was thinking about this a bit more and it seems like limiting ranges to >> targets that can generate sane results (i.e. error bounds within, say, 5-6 >> ulps) and for the rest, avoid emitting the ranges altogether. Emitting a bad >> range for all architectures seems like a net worse solution again. > > Well, at least for basic arithmetics when libm functions aren't involved, > there is no point in disabling ranges altogether. > And, for libm functions, my plan was to introduce a target hook, which > would have combined_fn argument to tell which function is queried, > machine_mode to say which floating point format and perhaps a bool whether > it is ulps for these basic math boundaries or results somewhere in between, > and would return in unsigned int ulps, 0 for 0.5ulps precision. I wonder if we could export frange_nextafter() to take a final argument for the number of ulps, making it possible to extend in either direction by a number of ulps. And perhaps add a generic function that calls the target hook and extends the range accordingly: extern int TARGET_ULP_ERROR (combined_fn, machine_mode); extern void frange_nextafter (machine_mode, REAL_VALUE_TYPE &value, const REAL_VALUE_TYPE &direction, int ulps); void adjust_frange_for_op (frange &r, combined_fn fn) { ... int ulps = TARGET_ULP_ERROR (fn, mode); frange_nextafter (mode, lb, frange_val_min (type), ulps); frange_nextafter (mode, ub, frange_val_max (type), ulps); ... } bool cfn_sincos::fold_range (...) { ... if (cond) { r.set (type, dconstm1, const1); adjust_frange_for_op (r, m_cfn); } ... } Or if adjusting by ULPS is a common enough idiom, we could promote it to an frange method: void frange::adjust_ulps (int ulps); Would that work, or did you have something else in mind? Aldy