From patchwork Thu Jan 23 18:14:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rogerio Alves X-Patchwork-Id: 37515 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Received: (qmail 51793 invoked by alias); 23 Jan 2020 18:14:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 51777 invoked by uid 89); 23 Jan 2020 18:14:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com To: libc-alpha@sourceware.org From: Rogerio Alves Subject: [PATCH] powerpc: fenvinline.h refactor Message-ID: <12b03cc3-0a23-ed07-e12d-8bdb6c7da9cb@linux.ibm.com> Date: Thu, 23 Jan 2020 15:14:10 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 Hi, Attached to this email is a patch to refactor fenvinline.h for power to include some __buitins when available. I also removed a weird asm constraint. I can't reproduce the warning described on the file and the test passed. Not sure why the put that constraint. I will appreciate any reviews. Regard From dbeca754bcbc6c77b6157a2f818554db31bac2ba Mon Sep 17 00:00:00 2001 From: Rogerio Alves Date: Thu, 23 Jan 2020 14:54:00 -0300 Subject: [PATCH v1] powerpc: Refactor fenvinline.h This patch refactor fenviline.h replaces some statements for builtins. 2020-01-22 Rogerio A. Cardoso * sysdeps/unix/sysv/linux/powerpc/bits/fenvline.h: Replace expression by __builtin_popcount. Use __builtin_mtfsb[01] when avaliable. Remove weird i#*X asm constraint. --- sysdeps/powerpc/bits/fenvinline.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/sysdeps/powerpc/bits/fenvinline.h b/sysdeps/powerpc/bits/fenvinline.h index 70689664e2..ae04ece189 100644 --- a/sysdeps/powerpc/bits/fenvinline.h +++ b/sysdeps/powerpc/bits/fenvinline.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see . */ - +#include #if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_FPRS__ /* Inline definitions for fegetround. */ @@ -51,9 +51,16 @@ # define fegetround() __fegetround () # ifndef __NO_MATH_INLINES -/* The weird 'i#*X' constraints on the following suppress a gcc - warning when __excepts is not a constant. Otherwise, they mean the - same as just plain 'i'. */ + +/* Builtins to mtfsb0 and mtfsb1 was introduced on GCC 9. */ +# if !__GNUC_PREREQ(9, 0) + +# define __builtin_mtfsb0(__b) \ + __asm__ __volatile__ ("mtfsb0 %0" : : "i" __b) + +# define __builtin_mtfsb1(__b) \ + __asm__ __volatile__ ("mtfsb1 %0" : : "i" __b) +# endif # if __GNUC_PREREQ(3, 4) @@ -63,12 +70,11 @@ int __e = __excepts; \ int __ret; \ if (__builtin_constant_p (__e) \ - && (__e & (__e - 1)) == 0 \ + && (__builtin_popcount (__e) == 1) \ && __e != FE_INVALID) \ { \ if (__e != 0) \ - __asm__ __volatile__ ("mtfsb1 %0" \ - : : "i#*X" (__builtin_clz (__e))); \ + __builtin_mtfsb1 ((__builtin_clz (__e))); \ __ret = 0; \ } \ else \ @@ -82,12 +88,11 @@ int __e = __excepts; \ int __ret; \ if (__builtin_constant_p (__e) \ - && (__e & (__e - 1)) == 0 \ + && (__builtin_popcount (__e) == 1) \ && __e != FE_INVALID) \ { \ if (__e != 0) \ - __asm__ __volatile__ ("mtfsb0 %0" \ - : : "i#*X" (__builtin_clz (__e))); \ + __builtin_mtfsb0 ((__builtin_clz (__e))); \ __ret = 0; \ } \ else \ -- 2.17.1