From patchwork Tue Apr 29 16:30:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 885758 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:38f:210b:807b with SMTP id g4csp425440wrq; Tue, 29 Apr 2025 09:41:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVA0aUwhLxVFAoe8JyVeVI7XbvqJSz9GSpxp6gKPwqXxTy7iZ2lodSUNbISYdAn+KsqjVdYQ==@linaro.org X-Google-Smtp-Source: AGHT+IGwdj11dZfz4XmAM2h/q4/IF/aa5WWtspkTorcyroYymFM1CWraUCQX+LO1xVjht73A9iVS X-Received: by 2002:a05:622a:5448:b0:476:8a27:6b01 with SMTP id d75a77b69052e-4886f5c0930mr69815831cf.47.1745944915673; Tue, 29 Apr 2025 09:41:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1745944915; cv=pass; d=google.com; s=arc-20240605; b=Jl8wSJhhWV5Bz431ViVWv+QyEJyfqh7UGUf83znKgD9vNSxN4sOrHx4AtkalzpViI5 sIbdlpxl+UyJFL77aRd7paPNyOZtXXKScchWYK+iyyzM4QsFvWyFJlyIkNqvxipIRuVJ 44z8lVLyJ8m6tmANRdGavHLNqh45giaVi1jFIBAUTn2herPTUsylOEiH9xgbZ4e5ijGv CtI/UAWu9HTeG9jZ34P20EjlvqBsuamIEl5hcrQpgvJbBmF5m1y2vuz6ioUgDQqBA0EY ZdAvLlvxGhwNcWkZfWGppMf9Qk8k91APhXBmJ86qlEZu7+2YX4R1+GtnOy43lt3H56Fa qYvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:dkim-filter:arc-filter:dmarc-filter :delivered-to:dkim-filter; bh=peOeEnZ9gmiNY1Evrbli58p7hEmp9XKxwJ12Ou4HLm4=; fh=QEQhASUpKkWwnOlb+v2n9KZRZHJ12Go9dzJxmOcjPvE=; b=OKVXA7HWjodov+tYk2813ARUbJ1KH/M9sjnTy32GC8d/aYsq3bSRWNMFwZz+eclzcW bzQpJaCcbJdzcdgPr13aK0cA4VIIhwi1VJXef6DVfoyk47RctdygZSHkx4g0wbJrrIkY 2HQCxpZShRP3BsCnrONNF1Nx7v6nhbV64ZsTw0fNVRnFIP+p1usBaRv98rVEnjOrpcyE Z3sefqJQNSrInVFtBOP83NwdnPAiv7+Oa3iayZj7vGmD1ere5SKPH4zU1jS17+MV7oDp odfslKrXiMyasOXJlPXLyypBVvku+9YtWtw70Xx2UaXxNE547cxi+DAaBiGqsyJ2pxEP O2Lw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ewa7vW1V; 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 d75a77b69052e-47e9fa9ac4bsi136115971cf.165.2025.04.29.09.41.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Apr 2025 09:41:55 -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=ewa7vW1V; 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 404CE3858C62 for ; Tue, 29 Apr 2025 16:41:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 404CE3858C62 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ewa7vW1V X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 3F3D5385842D for ; Tue, 29 Apr 2025 16:40:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F3D5385842D 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 3F3D5385842D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745944823; cv=none; b=kLOy2ojl3zuzsIxS0HLJCMR5gRltapQ/4SrTOP4krfzMa30nSDPvTiA61Zp/RTt4RUwDLSTvrqe0ZF7vIIOxZwHS+jv5JwyTSyLgxggW3eoEBgG2aepd/YEHNZBqABDszDcyVOza5sSumoYlsZiRKsXJaikbU9v4ee8dbvEserw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745944823; c=relaxed/simple; bh=asAB6KqwTTicusJuGVoh9tkTAgmJdQQKzTMC0lKCbro=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NYX5+A94XYOkV3If7w3A3D0WdHfSJe79VO/HMcZ0htTLu0JbZJvFJAU6YgeX6omGRTTnghHRSvpsqEkPvIrlt2azyG83SEN/w1sW8Tg4AIaJBIMkt4Fzu8/YjqUTKOY00gq5VD7TGMDaZy6NQwvQWBbo/zxeJoxVI5E5AFR33Tg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F3D5385842D Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-736a72220edso6251650b3a.3 for ; Tue, 29 Apr 2025 09:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745944822; x=1746549622; 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=peOeEnZ9gmiNY1Evrbli58p7hEmp9XKxwJ12Ou4HLm4=; b=ewa7vW1VlaVyZ6uLkNH4Atm8k8eIo7H6Wn2zhymmk8YMt66SHGgcAWzr4sonmpaIvu P7pCBdJflcDrfffuytmBko4vEmaRteVoxECSKXkB+x4bulpvnZGZvhOqghQGJCovjkS7 s6cYq+aCaQt4/0VMAeMk2QXma0ajlv+DjD8ZsrHMhxEBwfRcT/xMn6er9a+7WFluocc3 f2lUNqKL7rAOQa2LGdmMIMOtezj5EkDrEqgLjHeDf/4R4MprmPu2ImVDQbrOwILtpehF mq9lfvXzeHv+t22O5Lg6c6DbSFOAyEk047q+cfzxu33WulZzX4BNfc/20OM1y3cbBvMR ++ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745944822; x=1746549622; 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=peOeEnZ9gmiNY1Evrbli58p7hEmp9XKxwJ12Ou4HLm4=; b=r6IIXXYWye8o11BH+BvECkTo+OatihuBsogR6n1Nj6R002dtOIrfr5wdJG+OkjkBUU n3x2x1d0C13nHGlMBATEK19MH3FIZcfSqTthvYsbKhwKkYb12ofJSt2pfDtzaONO1zHR Y1kzbViUQGhRU0ZIJs11g+sKGMXXM0FXj1hnoW8kZdHJsVefjgfof4mqGL/0rFdkWYuP gDm/xnobKFl14ENJAfw6OCZt6/AaIZ/0swRDRBmmPdmXLNXxx5oOzMpZ01i8IWfuG0ax rRVZXT5qYk5fK3zHliSQbgnfV2wSmQbP/P/i56956KIyzrjSreMkR0TViqwpjbipNTDK rIDA== X-Gm-Message-State: AOJu0YymcTVOtUM01oARzJrCz9P1n291W9lNKOAIm+4i+87njl07XVm7 /ZWn0Cb1QOV3hRe+3hHcUnqb65O+YgYJzkY7bZfgp3zWpg7/p5BCdWpanwhfYLAU0e+jBZCjliJ I X-Gm-Gg: ASbGncu1A6XtmH7U+n63zVHcdTHzsIu2SJCcWy7sOd8hHPh2CkKqOJ1mcXnRZCsCGDP wwZPwrj3t2z1KcXuG52HlIK3lEfU7XZ+QGOaHpIxcaBYg/L2W5ymSv6CAQ9duvAM+kXBQcIlkbw 3QFuHi44FmDGa2NszEtqs9Q+EMvZ2QWianRIebbGX7RK5UcyAkQQmxOyZbTUQ4jDAQ87s7oRECh anPgbZ4Ge++86/lDun/xhTiNt8GJiAKQVh+9o7MD1eMiL0Ce6tmS6alULLNP+80HiwlaIds9wFs ps0kHoLIQIlOCNLLg9e3rCxCv0475r/Fl0ByOCsx4R39M6l9wUZFDg== X-Received: by 2002:a05:6a00:4648:b0:73d:b1ff:c758 with SMTP id d2e1a72fcca58-740293ae0bbmr4491629b3a.18.1745944822062; Tue, 29 Apr 2025 09:40:22 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:9bf1:b7a9:b8c3:bb3a:fca6]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e259134d5sm10492409b3a.19.2025.04.29.09.40.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Apr 2025 09:40:21 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Wilco Dijkstra , Xiaolin Tang , Peter Bergner Subject: [PATCH v3 5/6] math: Remove i386 ilogb/ilogbf/llogb/llogbf Date: Tue, 29 Apr 2025 13:30:03 -0300 Message-ID: <20250429164007.2928271-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250429164007.2928271-1-adhemerval.zanella@linaro.org> References: <20250429164007.2928271-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 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 new float and double implementation does not required an extra function call and error handling uses math_err function, which results in better performance on i386 as well. With gcc-14 on AMD AMD Ryzen 9 5900X, master shows: $ ./benchtests/bench-ilogb "ilogb": { "subnormal": { "duration": 3.68863e+09, "iterations": 1.72228e+08, "max": 89.2995, "min": 21.016, "mean": 21.4171 }, "normal": { "duration": 3.68878e+09, "iterations": 1.72948e+08, "max": 78.6065, "min": 21.127, "mean": 21.3288 } } $ ./benchtests/bench-ilogbf "ilogbf": { "subnormal": { "duration": 3.68835e+09, "iterations": 1.66716e+08, "max": 46.953, "min": 21.793, "mean": 22.1236 }, "normal": { "duration": 3.68784e+09, "iterations": 1.66168e+08, "max": 46.9715, "min": 21.904, "mean": 22.1935 } } While with this patch: $ ./benchtests/bench-ilogb "ilogb": { "subnormal": { "duration": 3.68134e+09, "iterations": 4.17516e+08, "max": 32.5045, "min": 8.3245, "mean": 8.81723 }, "normal": { "duration": 3.6677e+09, "iterations": 6.79468e+08, "max": 50.9305, "min": 5.3465, "mean": 5.3979 } } $ ./benchtests/bench-ilogbf "ilogbf": { "subnormal": { "duration": 3.67553e+09, "iterations": 5.11032e+08, "max": 35.927, "min": 7.0485, "mean": 7.19237 }, "normal": { "duration": 3.66877e+09, "iterations": 6.556e+08, "max": 26.3625, "min": 5.5315, "mean": 5.59605 } } Checked on i686-linux-gnu. --- sysdeps/i386/fpu/e_ilogb.S | 41 ------------------------------------- sysdeps/i386/fpu/e_ilogbf.S | 41 ------------------------------------- sysdeps/i386/fpu/w_ilogb.c | 2 -- sysdeps/i386/fpu/w_ilogbf.c | 2 -- sysdeps/i386/fpu/w_llogb.c | 2 -- sysdeps/i386/fpu/w_llogbf.c | 2 -- 6 files changed, 90 deletions(-) delete mode 100644 sysdeps/i386/fpu/e_ilogb.S delete mode 100644 sysdeps/i386/fpu/e_ilogbf.S delete mode 100644 sysdeps/i386/fpu/w_ilogb.c delete mode 100644 sysdeps/i386/fpu/w_ilogbf.c delete mode 100644 sysdeps/i386/fpu/w_llogb.c delete mode 100644 sysdeps/i386/fpu/w_llogbf.c diff --git a/sysdeps/i386/fpu/e_ilogb.S b/sysdeps/i386/fpu/e_ilogb.S deleted file mode 100644 index f4b792c27c..0000000000 --- a/sysdeps/i386/fpu/e_ilogb.S +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Public domain. - */ - -#include - -RCSID("$NetBSD: s_ilogb.S,v 1.5 1995/10/12 15:53:09 jtc Exp $") - -ENTRY(__ieee754_ilogb) - fldl 4(%esp) -/* I added the following ugly construct because ilogb(+-Inf) is - required to return INT_MAX in ISO C99. - -- jakub@redhat.com. */ - fxam /* Is NaN or +-Inf? */ - fstsw %ax - movb $0x45, %dh - andb %ah, %dh - cmpb $0x05, %dh - je 1f /* Is +-Inf, jump. */ - cmpb $0x40, %dh - je 2f /* Is +-0, jump. */ - - fxtract - pushl %eax - cfi_adjust_cfa_offset (4) - fstp %st - - fistpl (%esp) - fwait - popl %eax - cfi_adjust_cfa_offset (-4) - - ret - -1: fstp %st - movl $0x7fffffff, %eax - ret -2: fstp %st - movl $0x80000000, %eax /* FP_ILOGB0 */ - ret -END (__ieee754_ilogb) diff --git a/sysdeps/i386/fpu/e_ilogbf.S b/sysdeps/i386/fpu/e_ilogbf.S deleted file mode 100644 index 37298b9331..0000000000 --- a/sysdeps/i386/fpu/e_ilogbf.S +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Public domain. - */ - -#include - -RCSID("$NetBSD: s_ilogbf.S,v 1.4 1995/10/22 20:32:43 pk Exp $") - -ENTRY(__ieee754_ilogbf) - flds 4(%esp) -/* I added the following ugly construct because ilogb(+-Inf) is - required to return INT_MAX in ISO C99. - -- jakub@redhat.com. */ - fxam /* Is NaN or +-Inf? */ - fstsw %ax - movb $0x45, %dh - andb %ah, %dh - cmpb $0x05, %dh - je 1f /* Is +-Inf, jump. */ - cmpb $0x40, %dh - je 2f /* Is +-0, jump. */ - - fxtract - pushl %eax - cfi_adjust_cfa_offset (4) - fstp %st - - fistpl (%esp) - fwait - popl %eax - cfi_adjust_cfa_offset (-4) - - ret - -1: fstp %st - movl $0x7fffffff, %eax - ret -2: fstp %st - movl $0x80000000, %eax /* FP_ILOGB0 */ - ret -END (__ieee754_ilogbf) diff --git a/sysdeps/i386/fpu/w_ilogb.c b/sysdeps/i386/fpu/w_ilogb.c deleted file mode 100644 index 9c26217021..0000000000 --- a/sysdeps/i386/fpu/w_ilogb.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include diff --git a/sysdeps/i386/fpu/w_ilogbf.c b/sysdeps/i386/fpu/w_ilogbf.c deleted file mode 100644 index 047ad4bf11..0000000000 --- a/sysdeps/i386/fpu/w_ilogbf.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include diff --git a/sysdeps/i386/fpu/w_llogb.c b/sysdeps/i386/fpu/w_llogb.c deleted file mode 100644 index 5e8891a668..0000000000 --- a/sysdeps/i386/fpu/w_llogb.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include diff --git a/sysdeps/i386/fpu/w_llogbf.c b/sysdeps/i386/fpu/w_llogbf.c deleted file mode 100644 index edb7e9a9e6..0000000000 --- a/sysdeps/i386/fpu/w_llogbf.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include