From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id 7eada3a8 for ; Tue, 21 Jan 2020 03:54:10 +0000 (UTC) Received: (qmail 7540 invoked by uid 550); 21 Jan 2020 03:54:08 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7511 invoked from network); 21 Jan 2020 03:54:07 -0000 X-Authentication-Warning: key0.esi.com.au: damianm owned process doing -bs Date: Tue, 21 Jan 2020 14:53:53 +1100 (AEDT) From: Damian McGuckin To: musl@lists.openwall.com In-Reply-To: <20200117145350.GR30412@brightrain.aerifal.cx> Message-ID: References: <20200116161427.GO30412@brightrain.aerifal.cx> <20200116193343.GP30412@brightrain.aerifal.cx> <20200117145350.GR30412@brightrain.aerifal.cx> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Subject: Re: [musl] Considering x86-64 fenv.s to C On Thu, 16 Jan 2020, Rich Felker wrote: > Would you be interested in assessing what kind of abstraction makes > sense here? I think it is quite difficult, but eventually feasibly. Even having one abstract version for i386/x32 and x86_64 is not easy. My thoughts were to do an abstraction that works for at least those three, simplify this to be even more abstract, and then see how well it works for say something else. The i386/x32 and x86 are arguably among the worst as they effectively have 2 lots of status and control registers which are not synced on-chip but that need to be for MUSL. The only assembler in which I have even limited skills is Sparc32/64 which is not terribly useful for MUSL but in terms of an abstraction, may be as good as anything. I will be investing in an ARM soon but my skills will be starting from a base of none. On Fri, 17 Jan 2020, Rich Felker wrote: > As you said above, updating x87 status register is expensive because > the only way to write it is to read-modify-write the whole fenv. But > since we know on x86_64 we have sse registers, we can just move all > the flags to the sse register, then use fnclex to clear the x87 one > inexpensively, and the effective set of raised flags remains the same. > > I think we could do this on i386 too with a couple tricks: > > 1. Do the same thing if sse is available (hwcap check). Yes. > > 2. If sse is not available, clear all flags then re-raise the desired > set via arithmetic operations. That works. That said, Based on a comment earlier today, my thoughts are to use an arithmetic expression for the case where only a single exception was active, including the pairs INEXACT/OVERFLOW and INEXACT/UNDERFLOW, and use a fegetenv/set-register/fesetenv for anything more complex. Regards - Damian Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037 Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here Views & opinions here are mine and not those of any past or present employer