From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 5BCDC1F44D for ; Wed, 27 Mar 2024 19:42:00 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iUWOkDWA; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 606C7385E82F for ; Wed, 27 Mar 2024 19:41:59 +0000 (GMT) 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 D2A5E3858C31 for ; Wed, 27 Mar 2024 19:40:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D2A5E3858C31 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D2A5E3858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1029 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711568447; cv=none; b=CPKIl+nnNpLBLlk/WL7dxFX9AdJQv/UyIfZP7xQh/04Q4DWfajzOu1zSRce4cvXSJ/eU5IHDKBjn+sBw/kMPTVApwboTfvYG8rzV7j4i3Ug6wjfnso0AUbbMOK356RCW5nczX6SoEBdkmCyMLvgcO4LL2qyURcyb9vPuKASJd4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711568447; c=relaxed/simple; bh=7lsd+JEB6OXhLwzIRmgXKA+7kg76cGxq/9jNxZ2FcCw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=uLMKTNDJBAZW9s9BZMQZ+6nKvX4wqFKHFTMQJCasclJqDWtfo30rb1c6cFsgIBmqKQxtJLlpPKBRsOuk+5hkBa9ZwE+gxGIjX3/m1LtmvA2KYtUBeuAHvM7WyRhNyuv2bIfKPJ3zqBwhlwwV69zEewruuzMRiTpy20AZ28Xl8N4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-29e0229d6b5so190473a91.3 for ; Wed, 27 Mar 2024 12:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711568442; x=1712173242; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3gTSKqePJhhgVkKF2Oni/s3e8N6TubY4O/UTslyMKiM=; b=iUWOkDWAwntfN4m1j33YvcIzLJJ+drr9fZBRqCgrqDsigrTnUgWYBGcWzmblabFaGS YofY6Jlx3xgV7h5iOGrmg6BZ5vwol4L39GW5avj7C0sPcKp7MbhqvpGtLxLu6f7QLYFb XhsSbZciPowwIYiKzXi/N+/wHKYMj3OYONVmpKtOXjf18A23JQIskP1qbXTr0U/Is0HB MnW7zKyRXaAS7QZfcBUq6pAavHBta4XoZIM5wQLbIJcB8F+iJAEMCUD57vWbMxvET+AV TVcGt6eZnO3KSiCE46IfWZ2YOa50j2YA1prJL05ocDqx6a7oqzTnEroh6Lg0Woqiy+cx v56w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711568442; x=1712173242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3gTSKqePJhhgVkKF2Oni/s3e8N6TubY4O/UTslyMKiM=; b=sG7vObilIhJxGEAirdt9bkD+ULq5lkkfgGlUDiC60+wkeQ+l6FMgOvnl1K3p4ibVJR xn7X/LbU4js8aB3UCZFAeQjdq5BBmPj44qbtqtA9kpOSyfahwSx8/T2fERSqH2WqCAC5 SVQSDl9It1fxqIF+poHqFLsraiVBk8H1iY+2QoJZxO+/fjfUYBtYjDhJcLYAiuThNtsN VPYPqBpeilD2P9B5Z4XHJ28IywQvreJssv6U5QCdpzekHBosW9Fh3vlLW7qNpZHpjQ1g CJNI0C4iIjzcbUXtFNniO7l5tToOTmjXEx7H8w2pQ4IPCwlCIZ+fIrZYQv1p8xfwNEF7 7Pcw== X-Gm-Message-State: AOJu0YwIW/gIz/vcy5ekr4+ZAopcMEoVYjdj8xdayHxHIfY3yHdsP6UK zVZY8gqi0XXwPhEIftfC/fAec/xgOjAXEPIhwECw9hZ50jmmulVAXjTspRAKFGOxzTk0iOwrsM2 S X-Google-Smtp-Source: AGHT+IEqY6fZIIwwl8My87CCRWuE13hZzBLIFzcotKhTy+UnRrarZPX12LMoY4mS6LNJJf68uI+XyA== X-Received: by 2002:a17:90b:4c0f:b0:2a0:6bca:960d with SMTP id na15-20020a17090b4c0f00b002a06bca960dmr662737pjb.2.1711568442476; Wed, 27 Mar 2024 12:40:42 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:67c4:6248:3d8a:f386]) by smtp.gmail.com with ESMTPSA id p11-20020a17090a348b00b002a091be027esm2277357pjb.31.2024.03.27.12.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 12:40:41 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Joseph Myers , Florian Weimer , "H . J . Lu" Subject: [PATCH v2 06/10] i386: Use generic exp10 Date: Wed, 27 Mar 2024 16:40:20 -0300 Message-Id: <20240327194024.1409677-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240327194024.1409677-1-adhemerval.zanella@linaro.org> References: <20240327194024.1409677-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org The resulting performance is slight better (Ryzen 5900, gcc 13.2.1): * master "exp10": { "": { "duration": 3.70091e+09, "iterations": 5.8534e+07, "max": 91.279, "min": 62.6225, "mean": 63.2267 } } * patch "exp10": { "": { "duration": 3.70793e+09, "iterations": 6.328e+07, "max": 259.592, "min": 52.1145, "mean": 58.5957 } } Checked on i686-linux-gnu. --- sysdeps/i386/fpu/Versions | 1 + sysdeps/i386/fpu/e_exp10.S | 51 ----------------------- sysdeps/i386/fpu/e_exp10.c | 2 + sysdeps/i386/fpu/e_exp_data.c | 1 - sysdeps/i386/fpu/w_exp10_compat.c | 8 ---- sysdeps/ieee754/dbl-64/e_exp10.c | 7 +++- sysdeps/mach/hurd/i386/libm.abilist | 1 + sysdeps/unix/sysv/linux/i386/libm.abilist | 1 + 8 files changed, 10 insertions(+), 62 deletions(-) delete mode 100644 sysdeps/i386/fpu/e_exp10.S create mode 100644 sysdeps/i386/fpu/e_exp10.c delete mode 100644 sysdeps/i386/fpu/e_exp_data.c delete mode 100644 sysdeps/i386/fpu/w_exp10_compat.c diff --git a/sysdeps/i386/fpu/Versions b/sysdeps/i386/fpu/Versions index 9509f9b7c7..7326f25583 100644 --- a/sysdeps/i386/fpu/Versions +++ b/sysdeps/i386/fpu/Versions @@ -5,6 +5,7 @@ libm { } GLIBC_2.40 { # No SVID compatible error handling. + exp10; fmod; fmodf; } } diff --git a/sysdeps/i386/fpu/e_exp10.S b/sysdeps/i386/fpu/e_exp10.S deleted file mode 100644 index 902f70b77f..0000000000 --- a/sysdeps/i386/fpu/e_exp10.S +++ /dev/null @@ -1,51 +0,0 @@ - -#include -#include -#include - -DEFINE_DBL_MIN - -#ifdef PIC -# define MO(op) op##@GOTOFF(%ecx) -#else -# define MO(op) op -#endif - - .text -/* 10^x = 2^(x * log2(10)) */ -ENTRY(__ieee754_exp10) -#ifdef PIC - LOAD_PIC_REG (cx) -#endif - fldl 4(%esp) -/* I added the following ugly construct because exp(+-Inf) resulted - in NaN. The ugliness results from the bright minds at Intel. - For the i686 the code can be written better. - -- drepper@cygnus.com. */ - fxam /* Is NaN or +-Inf? */ - fstsw %ax - movb $0x45, %dh - andb %ah, %dh - cmpb $0x05, %dh - je 1f /* Is +-Inf, jump. */ - fldl2t - fmulp /* x * log2(10) */ - fld %st - frndint /* int(x * log2(10)) */ - fsubr %st,%st(1) /* fract(x * log2(10)) */ - fxch - f2xm1 /* 2^(fract(x * log2(10))) - 1 */ - fld1 - faddp /* 2^(fract(x * log2(10))) */ - fscale /* e^x */ - fstp %st(1) - DBL_NARROW_EVAL_UFLOW_NONNEG_NAN - ret - -1: testl $0x200, %eax /* Test sign. */ - jz 2f /* If positive, jump. */ - fstp %st - fldz /* Set result to 0. */ -2: ret -END (__ieee754_exp10) -libm_alias_finite (__ieee754_exp10, __exp10) diff --git a/sysdeps/i386/fpu/e_exp10.c b/sysdeps/i386/fpu/e_exp10.c new file mode 100644 index 0000000000..340254fc6e --- /dev/null +++ b/sysdeps/i386/fpu/e_exp10.c @@ -0,0 +1,2 @@ +#define EXP10_VERSION GLIBC_2_40 +#include diff --git a/sysdeps/i386/fpu/e_exp_data.c b/sysdeps/i386/fpu/e_exp_data.c deleted file mode 100644 index 1cc8931700..0000000000 --- a/sysdeps/i386/fpu/e_exp_data.c +++ /dev/null @@ -1 +0,0 @@ -/* Not needed. */ diff --git a/sysdeps/i386/fpu/w_exp10_compat.c b/sysdeps/i386/fpu/w_exp10_compat.c deleted file mode 100644 index 49a0e03385..0000000000 --- a/sysdeps/i386/fpu/w_exp10_compat.c +++ /dev/null @@ -1,8 +0,0 @@ -/* i386 provides an optimized __ieee754_exp10. */ -#ifdef SHARED -# define NO_COMPAT_NEEDED 1 -# include -#else -# include -# include -#endif diff --git a/sysdeps/ieee754/dbl-64/e_exp10.c b/sysdeps/ieee754/dbl-64/e_exp10.c index 225fc74c4c..c63b852f72 100644 --- a/sysdeps/ieee754/dbl-64/e_exp10.c +++ b/sysdeps/ieee754/dbl-64/e_exp10.c @@ -99,7 +99,7 @@ __exp10 (double x) /* Reduce x: z = x * N / log10(2), k = round(z). */ double_t z = __exp_data.invlog10_2N * x; - double_t kd; + double kd; int64_t ki; #if TOINT_INTRINSICS kd = roundtoint (z); @@ -147,7 +147,10 @@ __exp10 (double x) strong_alias (__exp10, __ieee754_exp10) libm_alias_finite (__ieee754_exp10, __exp10) #if LIBM_SVID_COMPAT -versioned_symbol (libm, __exp10, exp10, GLIBC_2_39); +# ifndef EXP10_VERSION +# define EXP10_VERSION GLIBC_2_39 +# endif +versioned_symbol (libm, __exp10, exp10, EXP10_VERSION); libm_alias_double_other (__exp10, exp10) #else libm_alias_double (__exp10, exp10) diff --git a/sysdeps/mach/hurd/i386/libm.abilist b/sysdeps/mach/hurd/i386/libm.abilist index 88e7538e51..01c5633663 100644 --- a/sysdeps/mach/hurd/i386/libm.abilist +++ b/sysdeps/mach/hurd/i386/libm.abilist @@ -1181,5 +1181,6 @@ GLIBC_2.35 fsqrt F GLIBC_2.35 fsqrtl F GLIBC_2.35 hypot F GLIBC_2.35 hypotf F +GLIBC_2.40 exp10 F GLIBC_2.40 fmod F GLIBC_2.40 fmodf F diff --git a/sysdeps/unix/sysv/linux/i386/libm.abilist b/sysdeps/unix/sysv/linux/i386/libm.abilist index c99c60161d..3413cfdbe7 100644 --- a/sysdeps/unix/sysv/linux/i386/libm.abilist +++ b/sysdeps/unix/sysv/linux/i386/libm.abilist @@ -1188,5 +1188,6 @@ GLIBC_2.35 fsqrt F GLIBC_2.35 fsqrtl F GLIBC_2.35 hypot F GLIBC_2.35 hypotf F +GLIBC_2.40 exp10 F GLIBC_2.40 fmod F GLIBC_2.40 fmodf F -- 2.34.1