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 12f90f4a for ; Mon, 20 Jan 2020 22:32:20 +0000 (UTC) Received: (qmail 23568 invoked by uid 550); 20 Jan 2020 22:32:19 -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 22523 invoked from network); 20 Jan 2020 22:32:18 -0000 Date: Mon, 20 Jan 2020 23:32:07 +0100 From: Szabolcs Nagy To: musl@lists.openwall.com Message-ID: <20200120223204.GP23985@port70.net> Mail-Followup-To: musl@lists.openwall.com References: <20200116161427.GO30412@brightrain.aerifal.cx> <20200116193343.GP30412@brightrain.aerifal.cx> <20200117145350.GR30412@brightrain.aerifal.cx> <20200120173804.GM30412@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [musl] Triggering Overflow (or Underflow) without triggering Inexact on i386 * Damian McGuckin [2020-01-21 08:11:50 +1100]: > I am trying to write arithmetic expressions using only x87 instructions to > trigger an exception. The ASM instruction to raise the flag in the status > register has way too much overhead. > > My normal technique of doing either of these would also trigger Inexact. > > e.g. > volatile long double t; > > Overflow: t = largest normal long double, t *= t; > Underflow: t = smallest normal long double, t *= t; > > Can it be triggered WITHOUT also triggering INEXACT? ieee operations raise inexact and underflow/overflow together. so you cannot implement feraiseexcept by only doing arithmetic ops (which can do individual underflow/overflow), but that's a rare function so it can be slow fldenv/fwait etc. note that there is __math_uflow/__math_oflow now for internal math code (and they don't use the smallest/largest normal, instead they use small/large numbers with simple representation since sometimes those can be constructed as immediates on some targets, but this is a micro-optimization).