From patchwork Fri Feb 1 12:48:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1034734 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99672-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="H97vHsJ2"; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Mna8+aAo"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43rcNN6nqlz9s4V for ; Fri, 1 Feb 2019 23:48:36 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=GbmdhBvF32pGHqbzd6A0bO2Sa9DMyUTkzu33TNrtoJ0jjxCFiHn1j BQgJKyobsaLYmywTWblt8/JzLM/OEBd2+8/Zf6P85EPrGY8j9iG9Qg5faIjy+dE1 ig/olgmdR8TNr4rereT6PK0E06xN3IDO5FS/1qfbyaR69h7zh6YNyQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=WO1+pByUqS+5t4ts/3f35TpZNMY=; b=H97vHsJ2C9GslvnSdnbRIL09O3vP Y7sZ/C+0b1/yrv082aNsgJGdqWS/xThwymstmImDTM/JnEdkEJYzvxHnaTH3N3LQ 7IoBnJV8aA+VSnIJ3IYDbTplE1Cdh10k9aWuu0NWUOV7Rys0Wt/N9kdHGzrADwTh Ancy0byA4BpyyMs= Received: (qmail 57414 invoked by alias); 1 Feb 2019 12:48:28 -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 57332 invoked by uid 89); 1 Feb 2019 12:48:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3051 X-HELO: mail-qk1-f196.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=jvTJFEI8MK/cYru1yrd2MhJe42Hr5xUZJeJUzASENAQ=; b=Mna8+aAocx0IYsaI/JoZBR5dnRYnBWTs5WW8M7XUMwFuM+1ARk+nUJW+DjKfAAPg8f wqnSLxPWsgY2I7lhJ7Y8wgzPrgzeUBpYQBywJz+PK/N38s+ub0/7MsOfEeLT8FhVWz5X MExjdmw76PkuP614b2YeJop39GLtjY0n1NCb4= From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] math: Enable some math builtins for clang Date: Fri, 1 Feb 2019 10:48:17 -0200 Message-Id: <20190201124817.11211-1-adhemerval.zanella@linaro.org> This patch enable the builtin usage for clang for the C99 functions fpclassify, isfinite, isnormal, isnan, isinf, and sigbit. This allows clang optimize the calls on frontend instead of call the appropriate glibc symbols. Checked on aarch64-linux-gnu and x86_64-linux-gnu. I checked the supported version for each builtin based on released version from clang/llvm. * math/math.h (fpclassify, isfinite, isnormal, isnan): Use builtin for clang 2.8. (signbit): Use builtin for clang 3.3. (isinf): Use builtin for clang 3.7. --- ChangeLog | 7 +++++++ math/math.h | 17 +++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/math/math.h b/math/math.h index ffbc24af09..d70ec3877c 100644 --- a/math/math.h +++ b/math/math.h @@ -874,7 +874,8 @@ enum the __SUPPORT_SNAN__ check may be skipped for those versions. */ /* Return number of classification appropriate for X. */ -# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ \ +# if ((__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (2,8)) \ && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus) /* The check for __cplusplus allows the use of the builtin, even when optimization for size is on. This is provided for @@ -889,7 +890,7 @@ enum # endif /* Return nonzero value if sign of X is negative. */ -# if __GNUC_PREREQ (6,0) +# if __GNUC_PREREQ (6,0) || __glibc_clang_prereq (3,3) # define signbit(x) __builtin_signbit (x) # elif defined __cplusplus /* In C++ mode, __MATH_TG cannot be used, because it relies on @@ -907,14 +908,16 @@ enum # endif /* Return nonzero value if X is not +-Inf or NaN. */ -# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ +# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (2,8) # define isfinite(x) __builtin_isfinite (x) # else # define isfinite(x) __MATH_TG ((x), __finite, (x)) # endif /* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */ -# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ +# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (2,8) # define isnormal(x) __builtin_isnormal (x) # else # define isnormal(x) (fpclassify (x) == FP_NORMAL) @@ -922,7 +925,8 @@ enum /* Return nonzero value if X is a NaN. We could use `fpclassify' but we already have this functions `__isnan' and it is faster. */ -# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ +# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (2,8) # define isnan(x) __builtin_isnan (x) # else # define isnan(x) __MATH_TG ((x), __isnan, (x)) @@ -939,7 +943,8 @@ enum # define isinf(x) \ (__builtin_types_compatible_p (__typeof (x), _Float128) \ ? __isinff128 (x) : __builtin_isinf_sign (x)) -# elif __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ +# elif (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (3,7) # define isinf(x) __builtin_isinf_sign (x) # else # define isinf(x) __MATH_TG ((x), __isinf, (x))