From patchwork Wed May 28 17:59:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 892979 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e0d:0:b0:3a4:ee3f:8f15 with SMTP id p13csp154831wrt; Wed, 28 May 2025 11:08:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUxYyBX1jnR6Ze2KBfGDi/ONHKORXr/k9xrBZfrFXr0y390xLHmlP1wwkll2ZjbhdgW7de3/Q==@linaro.org X-Google-Smtp-Source: AGHT+IHVIKc0m1EmP5yWvoIgFnOsRiv2OCAd1H/Dq4kbkBoSRugidBj97ZSVaKzoZZ7ValtC1BA+ X-Received: by 2002:a05:620a:2694:b0:7c7:93ae:fe56 with SMTP id af79cd13be357-7ceecc4253amr2623933485a.51.1748455703270; Wed, 28 May 2025 11:08:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1748455703; cv=pass; d=google.com; s=arc-20240605; b=LfZbfzznc+iL/Q4eU07u33CcfKvetfpgiZlkGrxqenPqBIkYsl84/gQf6LXqC2suHs 5Uvmd2XdQCMoEdrLWnnbelqvX45BfM1pkPZF0CUvG2AGbt7nQ4aChMmpGP2QB66jlUUC lPqVSa7qWntFV0OrpIL1fCHGqZVCu3n+NCkSB+fXEx2d5FGm3PXUEvyVxAIx6+tKXkLM pogtXEzYW6TEtcEJSAkYzPIBXSCK4aN1F/BsD512rNX0p2sww4AoheSJ1EiBvVQAHPge f1CBVurkncEhQeMY4ceeXh3But3Vr0LAm6lc2PoZ//lrm7CWk/6vxDZYdUzBaQYMhiTC iF9Q== 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=hJ4Yq8xfxWh412q6rbgYqckpTIde0mgnFLQvETrTxuY=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=lVHvGydmwWvrZoY7W8c391qEG48M9sazrLPxcrXR36nM+Cma1jdRXDmMEnMXf7LGLD Miwhr4G6Bi7yVoFcAuVL9VREIcTnjgSohtuLgGtprtr8xYc58QgnFN5B+Tz+6/GINjeG Gg625mvFHESZCj94laigIyMSaAwAWOVB9FSyXQ6+xR58SGsQa7rJ++97eI2GMHTv4hYT nQUyTJki0yHT1qZnuRJKPWUmVfp5BGE8syl5TFMgyCeA6T0jxOFJcxpjE4yB1N5DKi+0 gv+QnHxt53jrBJowdLX7Gk9H93mCkPQnZRcsQG5jhZxWmxJ7Iz09FCHqXxzNiBCrPeho ymhg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="keowm/XZ"; 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 af79cd13be357-7cfb81f7de5si177078285a.106.2025.05.28.11.08.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 May 2025 11:08:23 -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="keowm/XZ"; 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 C32AA385B538 for ; Wed, 28 May 2025 18:08:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C32AA385B538 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=keowm/XZ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by sourceware.org (Postfix) with ESMTPS id 050B2385608A for ; Wed, 28 May 2025 18:01:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 050B2385608A 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 050B2385608A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b36 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748455293; cv=none; b=Vv8saXpa1+hQR8z5+lriCDXuMgyCUeeTCLcZrO+Y7MJdCFnUZv70bLnenwkSVdERvkP71UDSn2KuKHWga3cNaQlHOlRvCtO2QfyjW8iw+bmYO1PQ5lR8G6560imjiCeQaAwC/bDx3HbWVOB9MzmqAdDFzg4kRFEAN4pumxfjDew= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748455293; c=relaxed/simple; bh=pJxEn6xZz9yak0jv+Q8lbzLTjyX+TlWU38Y917LPN9Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IjU9nliaNfF9Xfmvbb1DCJyxr81QTi88FR4Wgsg7k2peCK+pchuIZS8/zCYJlOBAMP7GrD+4con4HF+Fcxtu2K+3RpE609MngocSDAHfUsd7Bh0EoYKgeNEO69F6UuiJko4zW2Bh815YDdd1i9ptkWUB5hmwH9TsEwAseOssIp8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 050B2385608A Received: by mail-yb1-xb36.google.com with SMTP id 3f1490d57ef6-e7da171c504so80059276.0 for ; Wed, 28 May 2025 11:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1748455287; x=1749060087; 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=hJ4Yq8xfxWh412q6rbgYqckpTIde0mgnFLQvETrTxuY=; b=keowm/XZCZFWAenwHHrg/0amdcbzDtBX1LcyVOgSXh9j0t75Lf4NAbtlaMP7ygdYDI XOD3vPBF360H6K3+EfoHJOTcfZ4FuwFAKHXlUq+IRgBmEA2sQtpFTwX0OsKgrQaqqcQX /bXjRaNrRz+eft7f+8WZpfJM4Xi/YcsjmyWKsRXZYtmWHeoQUovYjka+9+qrjv4tqv1F zYtKNWQPBpGiBnBt6jfr1ApetcqaVll6dsoYIpttr8fzkO9lDhe+6KmYGZkwLTY1h7VA XPtdR8FE6qzpHlWQDRi3d6cJqE2Nh33rN+qHH06lqLqrC3fmVLmGfdqDdhz3hFXMcEFT B1dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748455287; x=1749060087; 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=hJ4Yq8xfxWh412q6rbgYqckpTIde0mgnFLQvETrTxuY=; b=wddDXOUOiJryLWqmtlj8YKh+j3Gca6zJHmyXhB80AmY/M5CwzODsQImy0AcF8rBw21 XSzmr45yF+XXxMBUOAdpVZOLjg2/PqmifxJmoM1N0EPhmAhLcm7hJE2ZU1QULP7WmPzG TvNOSeaX8VTWDmAo+tgzo+pONV9vXbDxVvv4mcqmny0yF4jpa0Z/OO3P09VKpHv6UJ25 MDUc2kT30RkI5D4lSsbyxdZQ2IPRmoe+ZGp9qJz9+RtRB47e8d4OXTZJ36up0RhirgAV Sdov8gN0fbrOcy00TEzIj3hUX4XHnqopHtT8cBS2F7LefOXW1/coCyGW6R2aHwvYDfyG QGaw== X-Gm-Message-State: AOJu0YyiJbkEzTzzPz4ZRr2qqaG4ZkcB8J+NAoqH713gQw3HiH9CbuVT zm+dhAHYhD6TH3g0xFcNUwAr37cf5b/rOG9zxg8o7o9GeFlsClawpNqPVZFpniAmzkYoydKjr11 qVQK9 X-Gm-Gg: ASbGnct48PUVPxZj+zIpghHvcerxhKMMz9kB1WW3kUu9oG4VRXI4Bg5nz94ZDczax/4 Pbq7OQx58hSmIi5gK+OYfqUaDJZg/z3MA4CeRKXjOn9UwG7BBwXF9pOMMTUTdmIR1fyAIB7fC+c 7TX5yQMWkLsg4c6/KAYGl52BEloYhnzTJ3WX+BycOCiIAiZiKqviNi1iM6BaX3wzUrktrXYERVs +jSL+OYGX07htkkvy7yKJMS9NywSgNpFsiK6DRLTUTg1le7G9NsuwH7Zc5s4HI41Fiy6PpGfRET fWvi3oqpywIA7inOOq61nFZTwMeXMcYR0Ee2A4rrY2ZPy7sD0fGcrJfi08VEvvs= X-Received: by 2002:a05:6102:6c5:b0:4dd:b86a:dac1 with SMTP id ada2fe7eead31-4e424063ea5mr16528077137.3.1748455276295; Wed, 28 May 2025 11:01:16 -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.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 May 2025 11:01:15 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 5/7] powerpc: Remove modff optimization Date: Wed, 28 May 2025 14:59:31 -0300 Message-ID: <20250528180100.172042-6-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.5210 1.3942 8.34% workload-1_maxint 2.0926 1.3940 33.38% workload-maxint_maxfloat 1.7851 1.3940 21.91% workload-integral 1.5216 1.3941 8.37% latency master patch difference workload-0_1 1.5928 2.6337 -65.35% workload-1_maxint 3.2929 2.6337 20.02% workload-maxint_maxfloat 1.9697 2.6341 -33.73% workload-integral 2.0597 2.6337 -27.87% Checked on powerpc64le-linux-gnu. --- sysdeps/ieee754/flt-32/s_modff.c | 2 + sysdeps/powerpc/fpu/math-use-builtins-trunc.h | 8 +++ sysdeps/powerpc/fpu/s_modff.c | 55 ------------------- .../power4/fpu/multiarch/s_modff-power5+.c | 2 +- .../be/fpu/multiarch/s_modff-power5+.c | 2 +- 5 files changed, 12 insertions(+), 57 deletions(-) create mode 100644 sysdeps/powerpc/fpu/math-use-builtins-trunc.h delete mode 100644 sysdeps/powerpc/fpu/s_modff.c diff --git a/sysdeps/ieee754/flt-32/s_modff.c b/sysdeps/ieee754/flt-32/s_modff.c index 6eb7fac989..db91814e25 100644 --- a/sysdeps/ieee754/flt-32/s_modff.c +++ b/sysdeps/ieee754/flt-32/s_modff.c @@ -64,4 +64,6 @@ __modff (float x, float *iptr) return asfloat (t & SIGN_MASK); #endif } +#ifndef __modff libm_alias_float (__modf, modf) +#endif diff --git a/sysdeps/powerpc/fpu/math-use-builtins-trunc.h b/sysdeps/powerpc/fpu/math-use-builtins-trunc.h new file mode 100644 index 0000000000..fd186d3510 --- /dev/null +++ b/sysdeps/powerpc/fpu/math-use-builtins-trunc.h @@ -0,0 +1,8 @@ +#define USE_TRUNC_BUILTIN 0 +#ifdef _ARCH_PWR5X +# define USE_TRUNCF_BUILTIN 1 +#else +# define USE_TRUNCF_BUILTIN 0 +#endif +#define USE_TRUNCL_BUILTIN 0 +#define USE_TRUNCF128_BUILTIN 0 diff --git a/sysdeps/powerpc/fpu/s_modff.c b/sysdeps/powerpc/fpu/s_modff.c deleted file mode 100644 index 79eeb7b810..0000000000 --- a/sysdeps/powerpc/fpu/s_modff.c +++ /dev/null @@ -1,55 +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 - -float -__modff (float x, float *iptr) -{ - if (__builtin_isinff (x)) - { - *iptr = x; - return copysignf (0.0, x); - } - else if (__builtin_isnanf (x)) - { - *iptr = NAN; - return NAN; - } - - if (x >= 0.0) - { - *iptr = floorf (x); - return copysignf (x - *iptr, x); - } - else - { - *iptr = ceilf (x); - return copysignf (x - *iptr, x); - } -} -# ifndef __modff -libm_alias_float (__modf, modf) -# endif -#endif diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff-power5+.c index 69591da43f..15bfa0bba9 100644 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff-power5+.c +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff-power5+.c @@ -17,4 +17,4 @@ . */ #define __modff __modff_power5plus -#include +#include diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-power5+.c index 69591da43f..15bfa0bba9 100644 --- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-power5+.c +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-power5+.c @@ -17,4 +17,4 @@ . */ #define __modff __modff_power5plus -#include +#include