From patchwork Wed Mar 27 19:40:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 783152 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2374922wrt; Wed, 27 Mar 2024 12:41:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4PWqy3WuJwV3dPhZXUW4NE1az3jmusTn939wd03kezaLFlkmT7j64p7qJoIGrE/OWC59gZMcv5hiKkncBghqn X-Google-Smtp-Source: AGHT+IFA5eZv/r0bJcsfx/h57DUZ654S6DmDJuRMo6r5E5tHIw7Vp4Wvb6nIpKfCvIM/pwYy9KWJ X-Received: by 2002:a05:622a:1708:b0:431:38a4:ef47 with SMTP id h8-20020a05622a170800b0043138a4ef47mr760227qtk.48.1711568501996; Wed, 27 Mar 2024 12:41:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711568501; cv=pass; d=google.com; s=arc-20160816; b=EvF9Iepk7vL1n6/AIDmCXtJc8oJ/6E7MxtpmDd+cKL/opy17a8s5UyD0c6fSCJLWYd BeCWo3v185Tyd074HMKZ4Psy6uaZ6PY++krYhXyEHpf9ofEWKxP7++H8iLwzz4ZLIuNy WElhwPxT4k/q2Oy0dKk6bAlnEl4wMvCnyEKGrkp2Cl4seNQKGPzNGp+XvYooZ//mBaqu oxuCHwuSqXJmBmkGgyD4p89R17Z7olNQcjRv1pXrdOalAzHn2i5caerKJf5CayFSsxOQ ibAIc3FRWWsRmWCGVjE+s0HoMsoLqlLwTSG7Lu3MRyvkBu2ce38BDRSWbzzKLscAZyvu yb8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=3gTSKqePJhhgVkKF2Oni/s3e8N6TubY4O/UTslyMKiM=; fh=WtLnUd2EuDKv+EP3BSdEI8hdivapDDAq3MY9+WgWrlk=; b=0cXG0upaWZ1AMM3kKivAxJBtga2Zz5KGT+yIDz5pfESofF8YnRc0w2StAK+TKDNr+P kOw46sGh+D6fPIZfiQHm/gchx4ZzQIM83siclOjFCJJZLsGixO+yRALD5kkRbINVG1mB GYSVLXkCWfXF3L/9jfxkw5JyD+gD4+8x+MBb2jpZ7ILjBNjb8zcnZz7zUgKRAevLip63 AOQDeykFrDqAPmkx5MW9unEg1KTa9CkwaxiBofIfCsrIyG+8XlP1qNVjOl6pdSUrVvMH xZ7RaZhX6F/8jM9gTepgDAbWFoL5dEkgPXhHze64/bxktWAZhZf4/U/FHUhwwYjOhIm4 7rAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iUWOkDWA; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id t42-20020a05622a182a00b00430d9904cb3si10168538qtc.632.2024.03.27.12.41.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 12:41:41 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iUWOkDWA; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8FB9F385E450 for ; Wed, 27 Mar 2024 19:41:41 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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-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 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patch=linaro.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