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 X-Patchwork-Id: 157193 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp382952jaa; Fri, 1 Feb 2019 04:48:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN53TuTv1TzFLsdOkCD+u8rCfslAmf5xxpUiIv1Y/WAWqPjGJJpublFVf6qOamtf4LTT0oKK X-Received: by 2002:aa7:85d7:: with SMTP id z23mr40611196pfn.205.1549025320648; Fri, 01 Feb 2019 04:48:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549025320; cv=none; d=google.com; s=arc-20160816; b=QlKV/woiI2zfCFhEIHfkahgyGtVHchyzBebtKMFMViyD5boaD4xRVz1fjUfB6H80d5 PHmWEGPPvYMgWMIxmnBN+UsSIS7gViUldl2rJZ62I/sKuzq4ItNB3pvxOy8IIEL120pa 2X+QSV20BFzCSjvGuhvqsam/dcx+Xl8kPAgcOcUON0nkoKgQBrXH+PQ7iisIN56C4DAa vMwUdOBtTkqqJTqy0u9zzunVRnApgq+FS6979MQnXRIr0/4bJCpp54h0mBmcS3ISHJ9Q ncmhHrDl1uJlhcgAxvTqH9D0n69BShfhlMxFXCALpShFQsi38ti1I4Zv5a5vItl+Q2e+ Fcqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:dkim-signature:delivered-to:sender :list-help:list-post:list-archive:list-subscribe:list-unsubscribe :list-id:precedence:mailing-list:dkim-signature:domainkey-signature; bh=jvTJFEI8MK/cYru1yrd2MhJe42Hr5xUZJeJUzASENAQ=; b=kI8/xvm5SvZzdMaQpmWT1q046k51iUV55JYLXUzCIeYV2BfCZJUgiHaAci03ZdFdDg twKCfZo2eEhLlujYBSPDCGLmbGTfcsmS2VkLo8r0kJCvliZgZSMXRJfEYpctYhNLVbdA 9kiM169j/Ez/N1lCyKAeS+rRoJQ1FaTSEyvGC8KTBbJS5b2ncXbj0YwagBMp1oiSPfZq NsC4szfru4swm1skPA3iQMx3qTlA1Sna6Q8a4/rQgQGde1SkHeMlFdlUyBreQ+wVPfqt azrdCq5Vj9qfm79Hg9h5KsdIqRhMMCCM8se7Z0b4Fc8uAEVYAVvQKDUHLuGw2JHmavfK RT/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=mAe0D3jU; dkim=pass header.i=@linaro.org header.s=google header.b=Mna8+aAo; spf=pass (google.com: domain of libc-alpha-return-99672-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-99672-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l38si7575324plb.48.2019.02.01.04.48.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 04:48:40 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-99672-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=mAe0D3jU; dkim=pass header.i=@linaro.org header.s=google header.b=Mna8+aAo; spf=pass (google.com: domain of libc-alpha-return-99672-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-99672-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=wjZkEjUk30b2bNZImRagGsLmRSqdqvlqj0M6rB79KTNR9hXKsDCdy zML0S0AWU6caDTsyQdSBWNqPDYWSTdG06k4BSKDf2leg92Ini6WU2zpjVYwLWi1/ MUUcE5PUY2xGgf0OJraVSSLSeSngKB3QURSqsmu7hO9Z76I0yg8Pp0= 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=mAe0D3jUuFj/U86cMSuykKuzwxc2 ergRImPJLXrs+57Hh7Y6upwxVT9127yHMoHdTVvI6fFeOxq0G/NFdjOYHOoNBHxs FKh+swbYPW2nPmZ+4yWhxZYGsgdFvMVlyc+TzEuC0TWTiKZ8cUvFhinOmLPJT6vZ YHYQDtXbKFmL2+A= 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= Return-Path: 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(-) -- 2.17.1 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))