From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id F1E9238515D6 for ; Fri, 26 Aug 2022 16:07:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F1E9238515D6 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1029.google.com with SMTP id r15-20020a17090a1bcf00b001fabf42a11cso2220945pjr.3 for ; Fri, 26 Aug 2022 09:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc; bh=SDguSfbTOefktuAe1QOVCF3t4JEV6IcMbQf9Ovahu6U=; b=IYInNxvhoHr1TbxxL4CLsrDd7x4Y+QYwCBv8jS/VHA1yeuPItbAu7qSSMH5z7MYMNc WvD/yOy1WvlZgpdohboSIfsFTbW7NWgThxHBOCz+AHUmyhpuOe2gt9nxdbIH7e0uTwP4 YDgstiTRjb4z2V9IBhqTerlPV2AxGT3UkiQiC11fdEQclFupLY/X7Cn4c1VETW/HrcuG AblDNBUCzAt49MfsELKYDyy104bxmqPp7xuelpcBtU8uQxH0ZYosXEFeXxP1AJ1aCng4 DF79g+RTIT6/cRZi8PrkCu77BmfO9cPO5kPqv1dNcADT5fXSkNmA27tRmJjETQtddAS7 Hx9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=SDguSfbTOefktuAe1QOVCF3t4JEV6IcMbQf9Ovahu6U=; b=P7DheZIh/5JecbxKfpRj/RMrOGvRsE6uP5YT5uJjb6Y0QAtnU+cJRVql6u6yxcAxcn gr31UB9t3SMHS3TocShtrRvTABDY8rvUGi1bVuxgXtoNeMYLzaQDwUuSHKZKyPUECYAY 2d3ofa9rF+NHSgUT6jbH+M/fb/aJER2M7vixziLZe2/KFT++njrhDW5QQ5IZXjz+iVdF uzoCqzlmp1wRuDap8JRUnMWNgiRsdo+jGkoDeJKFX8CZS/pCrFzuVdzdFAOb01p0p2Pm 0jHTSDk/6oiIY/gimYdj7py1HwB6PwmAoNSwgnZzxX+3+FSG4s686RtqhGo5JtdujgxR B+lw== X-Gm-Message-State: ACgBeo2m+ZIxG8dUJejs8pfEEQMVZEclnFxvNpCrxua3COKJaE6iWavQ szrcZfq118tMzRWZ7kF1L3shDBzMCIM= X-Google-Smtp-Source: AA6agR45TL6Cdu3bzYzSa5Mx9O5cMsfjtOChgdayMZbQpC6dJeqW1v/wmYwj15KraI6JiGkw/phrgQ== X-Received: by 2002:a17:902:eccb:b0:174:5227:ace6 with SMTP id a11-20020a170902eccb00b001745227ace6mr921351plh.18.1661530066282; Fri, 26 Aug 2022 09:07:46 -0700 (PDT) Received: from [172.31.0.204] (c-73-98-188-51.hsd1.ut.comcast.net. [73.98.188.51]) by smtp.gmail.com with ESMTPSA id s6-20020a625e06000000b0052d52de6726sm1958572pfb.124.2022.08.26.09.07.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Aug 2022 09:07:45 -0700 (PDT) Message-ID: <845babb7-4bb2-35d7-224f-13937b5a0aab@gmail.com> Date: Fri, 26 Aug 2022 10:07:44 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] Add set/get functions for negative infinity in real.* Content-Language: en-US To: gcc-patches@gcc.gnu.org References: <20220823103321.879429-1-aldyh@redhat.com> From: Jeff Law In-Reply-To: <20220823103321.879429-1-aldyh@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 8/23/2022 4:33 AM, Aldy Hernandez via Gcc-patches wrote: > For the frange implementation with endpoints I'm about to contribute, > we need to set REAL_VALUE_TYPEs with negative infinity. The support > is already there in real.cc, but it is awkward to get at. One could > call real_inf() and then negate the value, but I've added the ability > to pass the sign argument like many of the existing real.* functions. > > I've declared the functions in such a way to avoid changes to the > existing code base: > > // Unchanged function returning true for either +-INF. > bool real_isinf (const REAL_VALUE_TYPE *r); > // New overload to be able to specify the sign. > bool real_isinf (const REAL_VALUE_TYPE *r, int sign); > // Replacement function for setting INF, defaults to +INF. > void real_inf (REAL_VALUE_TYPE *, int sign = 0); > > Tested on x86-64 Linux. > > OK? > > gcc/ChangeLog: > > * real.cc (real_isinf): New overload. > (real_inf): Add sign argument. > * real.h (real_isinf): New overload. > (real_inf): Add sign argument. Funny in that I've fairly recently had the desire to do something a bit similar.  Let's consider 0.5, which we have a dconsthalf, but we don't have dconstmhalf for -0.5.  To get that value I create a dconsthalf object and flip its sign.  Similarly for a variety of other special constants (particularly powers of two, but a few others as well). Consider making the "sign" argument a boolean.  It's defined as a single bit bitfield in the real_value structure.   We don't want folks to pass in values outside [0..1] for the sign if we can easily avoid it:-) jeff