From patchwork Tue Apr 29 16:30:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 885761 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:38f:210b:807b with SMTP id g4csp428826wrq; Tue, 29 Apr 2025 09:48:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXj1vJZNWWTe6pE/vTPduO7TLMzWBp6LtcmgqPacxcfAsIw7X6YSXFLKZqFjRtPA4ckpfqunA==@linaro.org X-Google-Smtp-Source: AGHT+IGqAkuwtJNS6xexjRdMf/ALagKp1QZ6GgfVKXU0Oy72z5LEchgzYKQ2t5RwjWF2WMgK5R+x X-Received: by 2002:ac8:5a41:0:b0:476:9847:7c6e with SMTP id d75a77b69052e-48131806b46mr215121321cf.19.1745945330854; Tue, 29 Apr 2025 09:48:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1745945330; cv=pass; d=google.com; s=arc-20240605; b=Rp9QC7C4TaYHigMu1DcZcVrJih3zOYnYiKBryPZp9zI4yu+8kP4FPids36IejuW/gU AHNbCzCOFZt+9PkAvon+6w3/jmgAEZ8ok+kS8iyTrLZzhAPTqOm4y2SNtLtO/pED5gb/ XgTEhBLrkZ5u0B0BzNRHUD01RlL8mRNVgvTyzCeMulWnDWdXsZnUOodTU5MpybuA7UwU VpkL5eAXLX/Tqj+C5xSCYwHSQI8kngkSTIF8+onCilTpAUfOuoxLKyo2HKmQKqFgYzMV xb4dqFl1/a0kmr78xXaA22AFGbF0zfDRfeqmaQy80iFJoiaGiOX7M8IxDc0UhynSIvlX YNOQ== 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=zGNSlJP39M1RPnDh+109OnWxrYt16t+QNEiMMtXqH8k=; fh=QEQhASUpKkWwnOlb+v2n9KZRZHJ12Go9dzJxmOcjPvE=; b=EmcqfSQfGfkRroTkXO7+yrzpJ0Fh+799WrQ+gNe53rKzCeWfWQFKC6be7MuHnJS1FC P0AwYy7nkEW4707X/WmLHx6VLINNPAirXoZlPcut290TtXO2+TX8YnoYh68tR8+B6oT9 EK6rXedRsdHqXENb1/wIPbuRBFM9/uBQdzp7Rmy0McPjGHvSncc44JpZmiOtUHm1bv9S 5nnvVZfkuat+Ei+6WEsKEl8Y7Rha2X5MWgyF1Oz8yAfWMNIttT3DeE4Y+9TRuYTfbVl5 TBjoJuFvATWeF3vbSX3mrY4Y6xjCAE2OmvN7frK12oJdP4QIn72yqawHqN4fGORIZu59 UffA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HvKnwNKY; 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-47ea26a52c4si128133971cf.571.2025.04.29.09.48.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Apr 2025 09:48:50 -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=HvKnwNKY; 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 674EC3858031 for ; Tue, 29 Apr 2025 16:48:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 674EC3858031 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=HvKnwNKY X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id 782C53858C50 for ; Tue, 29 Apr 2025 16:40:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 782C53858C50 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 782C53858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745944825; cv=none; b=NZEapYEvU13NcyPeJm+R/uXeQ6FpvzZsUSMV4aESHbO9e1eeIzoz0TbTCbAwF6v5MDNaigo5VA6Y7lSJ79OMlAgaJMGuL4m4qvkrCLwNn7d9iUkKbUGcmDISdlS9ztkhoG6ByTQKl0hetkxxF1DfQRgAxiGyiOGoGLhHWx929DQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745944825; c=relaxed/simple; bh=UPoQSJWYfoh7RMBhr8POkdWM7ToBWW2764WZVBax+Dw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=n6t3oJLY/GGdKjhj8NgiaD9xqHqLYgi54btP4OOGO/41Pv2OjIR7v6pnghtepM8nZKSXAyfkvGevkRtbfDso57gBzVXvH6MW73bWNgtV0XER4YByFV3B1AK5UuEFPFUM1AWrYRmOTFWw/Zo0NHPU9emsVkbEqFojJC3COEINSG8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 782C53858C50 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-b06e9bcc986so4850837a12.0 for ; Tue, 29 Apr 2025 09:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745944824; x=1746549624; 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=zGNSlJP39M1RPnDh+109OnWxrYt16t+QNEiMMtXqH8k=; b=HvKnwNKYS5j3+Yn5kIW5+pJM+2gUwWQHb5nTihVVRUperzCQddubJn5soZNEG/8KWy mE0+Mnuau12/xZr3MMkhXXtGj3/gfLWiTNI07n6s9BVk2wMJj66y0NoZYC4/pm3eet+5 NuTopYwuEa3rQdnfI5BTHAHfQ7uunSJAo2o5Zw1chXS61i3rtjSUCFjymPiGpaFLu7hV WxeHh5YDHYJvuGKI/2Nst/ZBrYY5IvvNNJRczOozTaVwxiELiI/3l6BwfNBs/AQO86o9 KF/dyYQw/VhkaqY5JZkhRv2tsCTyUWad2oAS8RGtNYkEWWU96HvrEW8RKd3E6FEPELNx l/cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745944824; x=1746549624; 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=zGNSlJP39M1RPnDh+109OnWxrYt16t+QNEiMMtXqH8k=; b=VRpTyyL5iHJyQmr/GtgPH5zPsefecgWw6DRXkZvFw3ahcnCpIvK9aCcz8CQGeLCXin KddHuyms4IqGMHd3qRqlOZ6v1qp0eoyin6voyJ1JnXYkwwzIND/825Vo/b8DmbaKxwrK as518PSJK+DwVebr4Oa0TqOX6Hc20Kiw+puCRWYk96MGVdAafWg6nNp0Fn30eO+LKzoc deDc9TYzztrxsZxbvdtY/6ccBxQE6Fw3lP8QwCQyWaYdDu1dZEdNyao4V8DKKGaImCIi HJaBTdSoSYW9Eyxk2omelBNYygAVqXLw+oaVNtniBvQkaLaJXfKRMFuLyxkTDBWqN+FL aN3A== X-Gm-Message-State: AOJu0YytB4TMSssTjD1L1w6tMk5NYyRVXWyvJKXyyBlg7kftnWJEjAIJ cLkwVvTJzBE4KjYZJFvLzfh9bcFqrLRxjFPGQIBWh2vxKZ4YNgS8FICt1q+FrtPC5j2Omup3S/n V X-Gm-Gg: ASbGncscmQv4u3Vd+nigTUZ6c0Z19I1t3ShgD46nzXoMz2ZiapHB2a+XGuwZDXtlx+P nwA18RH0UwCb8F6BzMXQEflhP+dlPUsP0FEguO0G5nOV8PwG7KYgeEh/9Q6xI4zcSEYGM7DDjWQ FCwL+GLILVPBnZ+IG10FMT7xh3wf04bERdii2nGoXuyh8QNZwpKDzC6A20Ekmc1nFG63Hkg2J5/ arzC0tU3iSrK5MHN6vD3rtTmQhFAEECP/0lIYaeAqgpHCYSFhmTOmr/A9Snl85myMSDCB/U+7DO sJDMcsmUTedruKV4F1HPOQIghlgYwnqycGj5iBqa1DqLq6Gq879vCg== X-Received: by 2002:a05:6a21:329b:b0:1f5:852a:dd81 with SMTP id adf61e73a8af0-2046a6c5a2dmr21349804637.34.1745944824048; Tue, 29 Apr 2025 09:40:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Apr 2025 09:40:23 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Wilco Dijkstra , Xiaolin Tang , Peter Bergner Subject: [PATCH v3 6/6] powerpc: Use generic ilogb/ilogbf and refactor ilogbf128 Date: Tue, 29 Apr 2025 13:30:04 -0300 Message-ID: <20250429164007.2928271-7-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 powerpc64 leverages the use of xsxexpdp and xsxexpqp for for both ilogb/ilogbf for float, double, and float128 types. However with the new generic ilogb/ilogbf, this is not really a gain anymore. On POWER9 with gcc-13, the xsxexpdp/xsxexpqp shows: $ ./benchtests/bench-ilogb "ilogb": { "subnormal": { "duration": 5.08829e+08, "iterations": 4.4588e+07, "max": 18.761, "min": 6.7005, "mean": 11.4118 }, "normal": { "duration": 5.04674e+08, "iterations": 9.9596e+07, "max": 7.386, "min": 5.0505, "mean": 5.06722 } $ ./benchtests/bench-ilogbf "ilogbf": { "subnormal": { "duration": 5.04918e+08, "iterations": 9.8732e+07, "max": 7.1595, "min": 5.0475, "mean": 5.11402 }, "normal": { "duration": 5.04971e+08, "iterations": 9.8744e+07, "max": 7.771, "min": 5.048, "mean": 5.11394 } } While the new generic implementation shows: $ ./benchtests/bench-ilogb "ilogb": { "subnormal": { "duration": 5.05389e+08, "iterations": 9.2644e+07, "max": 11.0355, "min": 5.4255, "mean": 5.45517 }, "normal": { "duration": 5.04667e+08, "iterations": 1.02388e+08, "max": 9.758, "min": 4.8945, "mean": 4.92897 } }[azanella@cfarm135 powerpc64le-linux-gnu-power9-gcc13]$ ./benchtests/bench-ilogbf "ilogbf": { "subnormal": { "duration": 5.05409e+08, "iterations": 9.238e+07, "max": 7.69, "min": 5.442, "mean": 5.47098 }, "normal": { "duration": 5.0456e+08, "iterations": 1.02012e+08, "max": 6.84, "min": 4.922, "mean": 4.94609 } } The xsxexpdp/xsxexpqp also adds some extra code size overhead since it uses the generic ilogb/ilogbf for 0/inf/NaN handling. It is still kept for float128, and this patch also optimizes it to avoid need to call extra generic symbol to handle not number inputs. On same hardware (POWER9/gcc-13) it shows the improvement: * master "ilogbf128": { "subnormal": { "duration": 5.09608e+08, "iterations": 3.3092e+07, "max": 28.845, "min": 6.824, "mean": 15.3997 }, "normal": { "duration": 5.05148e+08, "iterations": 9.1692e+07, "max": 7.744, "min": 5.377, "mean": 5.50918 } } * patch: "ilogbf128": { "subnormal": { "duration": 5.0586e+08, "iterations": 8.388e+07, "max": 7.3295, "min": 5.952, "mean": 6.03076 }, "normal": { "duration": 5.04783e+08, "iterations": 9.6608e+07, "max": 8.9255, "min": 5.185, "mean": 5.22507 } } Checked on powerpc64le-linux-gnu and powerpc64le-linux-gnu targetting POWER8 and with --disable-multi-arch on POWER9. --- sysdeps/powerpc/powerpc64/le/fpu/e_ilogb.c | 41 ------------- sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf.c | 41 ------------- .../powerpc/powerpc64/le/fpu/e_ilogbf128.c | 1 + .../powerpc/powerpc64/le/fpu/e_llogbf128.c | 1 + .../powerpc64/le/fpu/multiarch/Makefile | 2 +- sysdeps/powerpc/powerpc64/le/fpu/w_ilogb.c | 2 - .../powerpc64/le/fpu/w_ilogb_template.c | 30 ---------- sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf.c | 2 - .../powerpc64/le/fpu/w_ilogbf128-impl.h | 57 +++++++++++++++++++ .../powerpc64/le/fpu/w_ilogbf128-power9.c | 1 + .../powerpc/powerpc64/le/fpu/w_ilogbf128.c | 51 +++++++++++++++++ sysdeps/powerpc/powerpc64/le/fpu/w_llogb.c | 2 - sysdeps/powerpc/powerpc64/le/fpu/w_llogbf.c | 2 - .../powerpc64/le/fpu/w_llogbf128-power9.c | 1 + .../powerpc/powerpc64/le/fpu/w_llogbf128.c | 2 + 15 files changed, 115 insertions(+), 121 deletions(-) delete mode 100644 sysdeps/powerpc/powerpc64/le/fpu/e_ilogb.c delete mode 100644 sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf.c create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf128.c create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/e_llogbf128.c delete mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_ilogb.c delete mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c delete mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf.c create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128-impl.h create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128-power9.c create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128.c delete mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_llogb.c delete mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_llogbf.c create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_llogbf128-power9.c create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_llogbf128.c diff --git a/sysdeps/powerpc/powerpc64/le/fpu/e_ilogb.c b/sysdeps/powerpc/powerpc64/le/fpu/e_ilogb.c deleted file mode 100644 index 89e7498266..0000000000 --- a/sysdeps/powerpc/powerpc64/le/fpu/e_ilogb.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Get integer exponent of a floating-point value. - Copyright (C) 1999-2025 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include "math_config.h" - -int -__ieee754_ilogb (double x) -{ - uint64_t ux = asuint64 (x); - int ex = (ux & ~SIGN_MASK) >> MANTISSA_WIDTH; - if (ex == 0) /* zero or subnormal */ - { - /* Clear sign and exponent */ - ux <<= 12; - if (ux == 0) - return FP_ILOGB0; - /* subnormal */ - return -1023 - stdc_leading_zeros (ux); - } - if (ex == EXPONENT_MASK >> MANTISSA_WIDTH) /* NaN or Inf */ - return ux << 12 ? FP_ILOGBNAN : INT_MAX; - return ex - 1023; -} diff --git a/sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf.c b/sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf.c deleted file mode 100644 index 1c2a8a5ade..0000000000 --- a/sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Get integer exponent of a floating-point value. - Copyright (C) 1999-2025 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include "sysdeps/ieee754/flt-32/math_config.h" - -int -__ieee754_ilogbf (float x) -{ - uint32_t ux = asuint (x); - int ex = (ux & ~SIGN_MASK) >> MANTISSA_WIDTH; - if (ex == 0) /* zero or subnormal */ - { - /* Clear sign and exponent. */ - ux <<= 1 + EXPONENT_WIDTH; - if (ux == 0) - return FP_ILOGB0; - /* sbunormal */ - return -127 - stdc_leading_zeros (ux); - } - if (ex == EXPONENT_MASK >> MANTISSA_WIDTH) /* NaN or Inf */ - return ux << (1 + EXPONENT_WIDTH) ? FP_ILOGBNAN : INT_MAX; - return ex - 127; -} diff --git a/sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf128.c b/sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf128.c new file mode 100644 index 0000000000..4ec3582ae4 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf128.c @@ -0,0 +1 @@ +/* Not needed, implemented at w_ilogbf128.c */ diff --git a/sysdeps/powerpc/powerpc64/le/fpu/e_llogbf128.c b/sysdeps/powerpc/powerpc64/le/fpu/e_llogbf128.c new file mode 100644 index 0000000000..163d9e2523 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/e_llogbf128.c @@ -0,0 +1 @@ +/* Not needed, implemented at w_llogbf128.c */ diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile index 6d74f09912..72adc6463b 100644 --- a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile @@ -90,7 +90,7 @@ gen-libm-f128-ifunc-routines = \ e_acosf128 e_acoshf128 e_asinf128 e_atan2f128 e_atanhf128 e_coshf128 \ e_expf128 e_fmodf128 e_hypotf128 e_j0f128 e_j1f128 e_jnf128 \ e_lgammaf128_r e_logf128 e_log10f128 e_powf128 e_remainderf128 \ - e_sinhf128 e_sqrtf128 e_gammaf128_r e_ilogbf128 k_tanf128 s_asinhf128 \ + e_sinhf128 e_sqrtf128 e_gammaf128_r k_tanf128 s_asinhf128 \ s_atanf128 s_cbrtf128 s_ceilf128 s_cosf128 s_erff128 s_exp10m1f128 \ s_exp2m1f128 s_expm1f128 \ s_fabsf128 s_floorf128 s_log1pf128 s_logbf128 \ diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb.c b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb.c deleted file mode 100644 index 9c26217021..0000000000 --- a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c deleted file mode 100644 index b5c1c0aa9d..0000000000 --- a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#include -#include - -#if _GL_HAS_BUILTIN_ILOGB -int -M_DECL_FUNC (__ilogb) (FLOAT x) -{ - int r; - /* Check for exceptional cases. */ - if (! M_SUF(__builtin_test_dc_ilogb) (x, 0x7f)) - r = M_SUF (__builtin_ilogb) (x); - else - /* Fallback to the generic ilogb if x is NaN, Inf or subnormal. */ - r = M_SUF (__ieee754_ilogb) (x); - if (__builtin_expect (r == FP_ILOGB0, 0) - || __builtin_expect (r == FP_ILOGBNAN, 0) - || __builtin_expect (r == INT_MAX, 0)) - { - __set_errno (EDOM); - __feraiseexcept (FE_INVALID); - } - return r; -} -declare_mgen_alias (__ilogb, ilogb) -#else -#include -#endif diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf.c b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf.c deleted file mode 100644 index 047ad4bf11..0000000000 --- a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128-impl.h b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128-impl.h new file mode 100644 index 0000000000..dff5331331 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128-impl.h @@ -0,0 +1,57 @@ +/* Get integer exponent of a floating-point value. + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Use the double version of EDOM/invalid operation handling. */ +#include "math_config.h" + +static RET_TYPE +llogb_nan_inf_subnormal (uint64_t hx, uint64_t lx) +{ + if (hx <= 0x0001000000000000ULL) + { + /* Zero or subnormal. */ + if ((hx | lx) == 0) + return RET_INVALID (RET_LOGB0); + /* Subnormal */ + if (hx == 0) + return -16431L - stdc_leading_zeros (lx); + else + return -16382L - stdc_leading_zeros (hx << 15); + } + return RET_INVALID (RET_LOGBNAN); +} + +static inline RET_TYPE +IMPL_NAME (FLOAT x) +{ + uint64_t hx, lx; + GET_FLOAT128_WORDS64 (hx, lx, x); + hx &= 0x7fffffffffffffffULL; + +#if _GL_HAS_BUILTIN_ILOGB + /* Check for exceptional cases. */ + if (__glibc_likely (! M_SUF(__builtin_test_dc_ilogb) (x, 0x7f))) + return M_SUF (__builtin_ilogb) (x); +#else + if (__glibc_likely (hx < 0x7fff000000000000ULL + && hx > 0x0001000000000000ULL)) + return (hx >> 48) - 0x3fff; +#endif + + return llogb_nan_inf_subnormal (hx, lx); +} diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128-power9.c b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128-power9.c new file mode 100644 index 0000000000..9de3f2101e --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128-power9.c @@ -0,0 +1 @@ +#include "w_ilogbf128.c" diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128.c b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128.c new file mode 100644 index 0000000000..ae3e4a9e48 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbf128.c @@ -0,0 +1,51 @@ +/* Get integer exponent of a floating-point value. + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#ifdef DEF_AS_LLOGBF128 +# define DECL_NAME __llogb +# define FUNC_NAME llogb +# define RET_TYPE long int +# define RET_LOGB0 FP_LLOGB0 +# define RET_LOGBNAN FP_LLOGBNAN +# define RET_LOGMAX LONG_MAX +# define RET_INVALID __math_invalid_li +#else +# define DECL_NAME __ilogb +# define FUNC_NAME ilogb +# define RET_TYPE int +# define RET_LOGB0 FP_ILOGB0 +# define RET_LOGBNAN FP_ILOGBNAN +# define RET_LOGMAX INT_MAX +# define RET_INVALID __math_invalid_i +#endif +#define __IMPL_NAME(x,y) x ## _ ## y +#define _IMPL_NAME(x,y) __IMPL_NAME(x,y) +#define IMPL_NAME _IMPL_NAME(FUNC_NAME, impl) +#include + +RET_TYPE +M_DECL_FUNC (DECL_NAME) (FLOAT x) +{ + return IMPL_NAME (x); +} +declare_mgen_alias (DECL_NAME, FUNC_NAME) diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_llogb.c b/sysdeps/powerpc/powerpc64/le/fpu/w_llogb.c deleted file mode 100644 index 5e8891a668..0000000000 --- a/sysdeps/powerpc/powerpc64/le/fpu/w_llogb.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_llogbf.c b/sysdeps/powerpc/powerpc64/le/fpu/w_llogbf.c deleted file mode 100644 index edb7e9a9e6..0000000000 --- a/sysdeps/powerpc/powerpc64/le/fpu/w_llogbf.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_llogbf128-power9.c b/sysdeps/powerpc/powerpc64/le/fpu/w_llogbf128-power9.c new file mode 100644 index 0000000000..9550611b95 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/w_llogbf128-power9.c @@ -0,0 +1 @@ +#include "w_llogbf128.c" diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_llogbf128.c b/sysdeps/powerpc/powerpc64/le/fpu/w_llogbf128.c new file mode 100644 index 0000000000..0a67251faa --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/w_llogbf128.c @@ -0,0 +1,2 @@ +#define DEF_AS_LLOGBF128 +#include "w_ilogbf128.c"