From patchwork Wed May 28 17:59:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 892973 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e0d:0:b0:3a4:ee3f:8f15 with SMTP id p13csp151383wrt; Wed, 28 May 2025 11:02:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVg2humvojfZxyg5FmDv+m7MM73eZLfiCRGmZPwpTTfsmbn0eQNQAzt6wIQjOm9NyMV46PQ6g==@linaro.org X-Google-Smtp-Source: AGHT+IGlfScEEpDwLGfUTtvPs8JKO/QYtqYnE3M+zbfd4FHilJkpiEjIC3tRkOSvkoAzFXBqEnJA X-Received: by 2002:a05:6000:2309:b0:3a0:8291:20d0 with SMTP id ffacd0b85a97d-3a4cb461170mr12720325f8f.29.1748455333965; Wed, 28 May 2025 11:02:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1748455333; cv=pass; d=google.com; s=arc-20240605; b=KyUcA9TbxqHqGNo4/9w0x3ruvbdl2bW1d4OIx/UM1iKrK6Pjze1c3eaXXoF1cvF+b4 o8hgpCGDeehRPirI1nEMW/gdIVz3A+BXDaDo4JBEATUoF0vMYTKgaLzcMF6tTEclu745 pj0kBq6jaWkq0p6BrPtSZ3sWaQbCkkmTPHxHc+Qur5/SKu4Fn8Zolw1jYEpdRrGq4JZV RT5+qcwJcCqmg+58WDqZC9HUA0wnTua8aOJuBjRHkn+SPzAH0U/KITQ447FWqo1QUoHJ AwppvMufuRaUySF4pXzTeVEgjzLtv9W0Q9r5Jn8A/4uAOFQhvlVRNOD2R+zIBizJ/l+1 n+zg== 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:to:from :dkim-signature:dkim-filter:arc-filter:dmarc-filter:delivered-to :dkim-filter; bh=cd3z5zIsKjXz+21ffS/MmaytERaWXV4N50MGaiIvys0=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=aGpcbbrUQ3bAIBCY44/44nPNzIHu/l9kyPG5Mo/Fzp8zFYNaKK0o2btdBh9suOKzQ3 hMP+PWFTCKULaSXojIzev/yPLsOUCfSzyQ99QBpAImdWggPhoNUd4flSdidbEftN6OaI b4iJ0r/NxKS2BJkN356s43Xzw5mcAZFhXdHjJ2UmR/pBJysB3l+eX0JGQ6buXgAuCh/K rAT+Z9VTwWUOiiK/K1+uOOsqCuOnXJ+fH+maMLUNaqh9GoQcoQMdtaIC/fZFDfyhTC0t OeafmKCKmBGpDxA8vA3kUAEBNg45fMgsZvlQEfvIGz6FcSB+UUoUfnDXLFIW9pKcDrFj qBvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TAT6CbXl; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id ffacd0b85a97d-3a4eacc228csi1282771f8f.396.2025.05.28.11.02.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 May 2025 11:02:13 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TAT6CbXl; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 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 36CDC385C41B for ; Wed, 28 May 2025 18:02:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 36CDC385C41B 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=TAT6CbXl X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) by sourceware.org (Postfix) with ESMTPS id 5C493385B805 for ; Wed, 28 May 2025 18:01:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C493385B805 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 5C493385B805 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::e32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748455279; cv=none; b=k65sr/upc98CXhsNSzTjvuhBwpL1hwGQXxorlzNHk/wjLQq7sDvECoJ0tMICGcno1905TTQGDvrAJI1tWg5fQf10fboGDO7BaKHRycUbYqLXwqkz0es+8fGzcaY/rUcrH2KBjc6e+dSy3rcwvhDhMaGZFP/FBhX8CvsVhUlBd/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748455279; c=relaxed/simple; bh=GkVJaxcBAdSYx01gm1/MZXqNRzeUvu40AKn/3hfDuRs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AcWEg1nnyEb1vw7BZkQWJ8kWjnXCebH0rZawL/yBR90b0vPhK7LOuT5q+8xEgZhI4asrTtovhqxsqNvqNZWWBQ9Czc49cDJsk+rNyE/4GCfbjr3qnUCYHgX/Kdz1Otl8bZzIydr+hZtPHfDFqDVabnNbHvJtwTo5f37lW/cN4cc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C493385B805 Received: by mail-vs1-xe32.google.com with SMTP id ada2fe7eead31-4dfa2aeec86so26850137.1 for ; Wed, 28 May 2025 11:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1748455278; x=1749060078; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cd3z5zIsKjXz+21ffS/MmaytERaWXV4N50MGaiIvys0=; b=TAT6CbXlp9PP9rV82wSO21Spw+RFppv2jbtWRW1UAd0wZy8FtA8sUmSeBqMV45OMoV djv27Omzi6HDRhRdLDktKdZC0jAyfQ5XP6WTWnhZykvMLCnEdeuGhPKCM6bADGHzLcvV sJisuj89OPfNG8MOddVsQAHVK31E5te/BcdxX0MkT1kSIbmHwi9CyTV3QP81D2AtVVTG LOMktNsqANEzz/Vd+lsMN7pUN4Dfn5Uu9nPqOk0wL/UVUy6syfeeVl0I8phRPsAeNLRw zpE88a7NIR4LAtgooMM/iIo/qA1m3R5cpV5f9zk48vEupsweICztaKIfM2EFBmaNR3Pk ozpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748455278; x=1749060078; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cd3z5zIsKjXz+21ffS/MmaytERaWXV4N50MGaiIvys0=; b=CaOzBDojGYKuJeCnt3wnjzW710OLogUN2QaDrz42UnRlB2o0zCeCXocgpgizRa3usD DRypkz3ii0qFUYeAhIsBkCg0cQYrM8bLdUUds5YGnmBr9xvc3icGuZ/6FYfnHuJAL8z3 JRHxxtxEn0Pc3i1jIhd+++yjkk5kR6K7/66GOQbjoXVgYzofyPGUSgfw64G/1hodAE2l pqVlW0XSJLvHyTuKk9bKv+f7svZH98UU+DpOzU1y255ro3ZawO8ucTNtsK5itQXQz94a 3BN2rLLOp1GXlX11uLYzy+aDCFRUA6JC5Nm7UGC1PTT9l82NqQ01M15Coj+jPigRe6ad Y2Mg== X-Gm-Message-State: AOJu0YypbZNKzijVuyOiVtNhaOUPvFubPrhunisgyHpvSCRVUxVUupId 4hPt4UsNi/BnOLGbYgOQMQxM02Aoa8G4xF157KeOOoqVmqawDScgYS7vzcXxXH1B1mhhuHryI2+ qeHhm X-Gm-Gg: ASbGncsgIsvXCF5OU0mZxLaOJY7Wiooue09tmCSHLUfxYDhcRLUmXC2fAD4/nZhYc5p A3sQ0JJgbNT6ml+4D4VRx2MoCLONVWkfdLs/dYgrgH4LEcOscCF6Ltf3ggh4fu4rIubhdsJy/SB G83Wtywya62lscpGDVbE8PprEo5b8Z7aXAyo90TItqB0oYZLg/+rXdobiFsCUjpqrTCpBuz9hK6 bggfmyzcbXel4CezbmrjY4xHHPuS0lJ/bdfOTKvxs0TbtoB4ZZP8q0Z3HfF7R8wMF7gajf2Kled G8BJFf12wwbAGP/wJU9VWLUNqWp2LVfw3B7wzxMKHYHp0wSUHYwVi624PZbp5CQZOG6lAuK1fQ= = X-Received: by 2002:a05:6102:2912:b0:4e5:a83a:3cee with SMTP id ada2fe7eead31-4e5a83a402dmr2159948137.14.1748455277868; Wed, 28 May 2025 11:01:17 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:d17b:b9f7:b8cb:6df:3812]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-87e1f0db852sm1213969241.27.2025.05.28.11.01.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 May 2025 11:01:17 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 6/7] powerpc: Remove modf optimization Date: Wed, 28 May 2025 14:59:32 -0300 Message-ID: <20250528180100.172042-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250528180100.172042-1-adhemerval.zanella@linaro.org> References: <20250528180100.172042-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 generic implementation is slight more optimized than the powerpc one, where it has a more optimized inf/nan check (by not using FP unit checks, along with branch prediction hints), and removed one branch by issuing trunc instead of a combination of floor/ceil (which also generated less code). On power10 with gcc 14.2.1: reciprocal-throughput master patch difference workload-0_1 1.1351 0.9067 20.12% workload-1_maxint 1.4230 0.9040 36.47% workload-maxint_maxfloat 1.5038 0.9076 39.65% workload-integral 1.1280 0.9111 19.23% latency master patch difference workload-0_1 1.1440 2.7117 -137.03% workload-1_maxint 4.0556 2.7070 33.25% workload-maxint_maxfloat 3.2122 2.7164 15.43% workload-integral 3.2381 2.7281 15.75% Checked on powerpc64le-linux-gnu. --- sysdeps/powerpc/fpu/math-use-builtins-trunc.h | 3 +- sysdeps/powerpc/fpu/s_modf.c | 59 ------------------- .../power4/fpu/multiarch/s_modf-power5+.c | 2 +- .../be/fpu/multiarch/s_modf-power5+.c | 2 +- 4 files changed, 4 insertions(+), 62 deletions(-) delete mode 100644 sysdeps/powerpc/fpu/s_modf.c diff --git a/sysdeps/powerpc/fpu/math-use-builtins-trunc.h b/sysdeps/powerpc/fpu/math-use-builtins-trunc.h index fd186d3510..3e6a55d2ca 100644 --- a/sysdeps/powerpc/fpu/math-use-builtins-trunc.h +++ b/sysdeps/powerpc/fpu/math-use-builtins-trunc.h @@ -1,8 +1,9 @@ -#define USE_TRUNC_BUILTIN 0 #ifdef _ARCH_PWR5X # define USE_TRUNCF_BUILTIN 1 +# define USE_TRUNC_BUILTIN 1 #else # define USE_TRUNCF_BUILTIN 0 +# define USE_TRUNC_BUILTIN 0 #endif #define USE_TRUNCL_BUILTIN 0 #define USE_TRUNCF128_BUILTIN 0 diff --git a/sysdeps/powerpc/fpu/s_modf.c b/sysdeps/powerpc/fpu/s_modf.c deleted file mode 100644 index 831072bdc3..0000000000 --- a/sysdeps/powerpc/fpu/s_modf.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2013-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 Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If - not, see . */ - -/* ISA 2.07 provides fast GPR to FP instruction (mfvsr{d,wz}) which make - generic implementation faster. Also disables for old ISAs that do not - have ceil/floor instructions. */ -#if defined(_ARCH_PWR8) || !defined(_ARCH_PWR5X) -# include -#else -# include -# include -# include - -double -__modf (double x, double *iptr) -{ - if (__builtin_isinf (x)) - { - *iptr = x; - return copysign (0.0, x); - } - else if (__builtin_isnan (x)) - { - *iptr = NAN; - return NAN; - } - - if (x >= 0.0) - { - *iptr = floor (x); - return copysign (x - *iptr, x); - } - else - { - *iptr = ceil (x); - return copysign (x - *iptr, x); - } -} -# ifndef __modf -libm_alias_double (__modf, modf) -# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) -compat_symbol (libc, __modf, modfl, GLIBC_2_0); -# endif -# endif -#endif diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf-power5+.c index b8315c5b81..48f3a1997d 100644 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf-power5+.c +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf-power5+.c @@ -17,4 +17,4 @@ . */ #define __modf __modf_power5plus -#include +#include diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-power5+.c index b8315c5b81..48f3a1997d 100644 --- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-power5+.c +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-power5+.c @@ -17,4 +17,4 @@ . */ #define __modf __modf_power5plus -#include +#include