From patchwork Wed Dec 18 18:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 103372 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA52A385840C for ; Wed, 18 Dec 2024 18:57:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA52A385840C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=HsIswbc5 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 0A61D3858CD9 for ; Wed, 18 Dec 2024 18:51:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0A61D3858CD9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0A61D3858CD9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734547919; cv=none; b=UHzpPcHn263t/fZrwKc+n6VhfwhPoEW3FE2v51VdQCDOMBAURx4Fvj0vNokb4bWD/oF8/V8XXDFCtO0q+y1sWC5SNnah1xfwAmBbzM6/lDQknjkzJaN75JJQ3tHM1h/Wzghb6S5Nb/I86rNxpK8469PAKv+oJVih/4NkDTBNnq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734547919; c=relaxed/simple; bh=uHEGnO902n2CpGItRIGNiF2zNEsIzXOUviy0tI8W6Pw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UauMe76pQGqawnV0Ubz3+403FwNPT/sj0yRnLEM3n0q4ntvcz2/4+CiXbeCDwjtwb+jw1uVOqtCe749GbmAiEn/cmkfePRpdQpi3iikp0FlYItnwrDr8wCJPeSR1gxH3HJy0rdTuPetvkuRl219/0rgifOf8vgQE5CPW4cXe8NM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A61D3858CD9 Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-3a813899384so23394395ab.1 for ; Wed, 18 Dec 2024 10:51:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734547918; x=1735152718; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MDup+Vm+icznx/ycCA+5ABBjZgu+Ifb/ZiynXKtSiKo=; b=HsIswbc5/f1BseJ87iOn1ndZXbjXd3PdSyp9RGBtWMekVVy/piCqf6C46+ZinX7+aQ Gy6cTSh6ylVPzrIx3l/ph7T6QvOuAw0iZQOgEqX2RcciLhI0kNyi2lbYHEbHnhFpEmPI /cksg6mMQ2lKnpgRIe8cY4GaFaN2yikbnpu+x27D54GYMoTPSTLzjeXF2zDLeMu8FCLU 4qqTMkyYqcGUgccV0FTsnuUFLMoZ6P03wHpXKKebOuNct3LUkrzC6bue9YbDKm69FGCS VeWQsN4hp2XC45xbXCxJ3vERlXBfjbvlamVcMQ3v896ZsbgQ09UoZfeUB08QpCKH+6VB 0s4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734547918; x=1735152718; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MDup+Vm+icznx/ycCA+5ABBjZgu+Ifb/ZiynXKtSiKo=; b=pAUp5huXXiiWNCL08nEuyOWOzNz7FDizOidtHg5UAWQqV0NyTQxnFJ4EfDUlNUp7Z4 nx3hdgfUJwaJpATyvMd+cxSD09vzztEB3jysKqFTQE9FUfa15/yQ+bWsjNtE4PYQpMxh vBFiErlmjt8EljkTDYA4unsujpwVuJUpX7rbarFAtYG34j/CntrY098V8/C7lJceZvnv nWPloSOzbSA0KNBXT0/CbwXdB7Xo5pIfloGquZagj1wtsWYJgvMS3a52w7Ah2Bu8dT3e XKTYGrmoka6jJ31I+8A9FgxKtP8SaN5f72WGjCbWZLvyriPBaUMU3YaR1fdKVtPpXzo2 NdfQ== X-Gm-Message-State: AOJu0YwlhUxzeM0xC6lHyEDOq2z/xpe/TXHBzkO3o16Puts9RBM5mVWb uNRQYTldc+v63ArMKxEYU1/0VBYbbNMlfUve13hEu8Rv+2f5rn4p X-Gm-Gg: ASbGncvuLpleSrGF6+UhpVUxWyrKx1F6FDaYXjRsxrB9933S1S4SGP1yj4Cu6R7ALKb gN44OVXDFicMCQcQgstNwUJDSEGJtGt0nOYUeGASLR2RMqO2Mc0YkIGpju5FbJFNw3WFi9Kk2W3 nBOUqlW3bshWwfB8uuooqr/9UsavJ9ulKJCeLEAVTo4hj+tzE9oULE/VWc7cXwoyaxFVYEStN62 APOIZU4AfyuPBKyHmxMDltTrolTA9R4Dd5NEx8uh4DsgNAEpeuVmoKw3IOhydswyORgcPHiUXg6 J8oq4LMz8tJi3ssthsTyU+NXd42MSdm6HN87PmC/o24K X-Google-Smtp-Source: AGHT+IEXqsUHA3RILxJHaTV8imI5FjYDryr26OvIAvo+JlRPC4gMtDRAzcRPAIWWHCjmmOLeQsLUVQ== X-Received: by 2002:a05:6e02:13af:b0:3a7:e8df:3fde with SMTP id e9e14a558f8ab-3bdc0bc7851mr38182935ab.9.1734547916063; Wed, 18 Dec 2024 10:51:56 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.139.71]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3b2475afaf2sm28179955ab.15.2024.12.18.10.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 10:51:55 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id E2D4AC0231; Thu, 19 Dec 2024 02:51:50 +0800 (CST) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: Fangrui Song Subject: [PATCH] x86: Define __HAVE_FLOAT128 for Clang and use __builtin_*f128 code path Date: Thu, 19 Dec 2024 02:51:47 +0800 Message-ID: <20241218185147.2444092-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3017.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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~patchwork=sourceware.org@sourceware.org From: Fangrui Song Clang supports __builtin_fabsf128 (despite not supporting _Float128) but it does not support __builtin_fabsq. Fallback to back to `typedef __float128 _Float128;` it clang is used. --- sysdeps/x86/bits/floatn.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sysdeps/x86/bits/floatn.h b/sysdeps/x86/bits/floatn.h index e661abaea4..8849b811bc 100644 --- a/sysdeps/x86/bits/floatn.h +++ b/sysdeps/x86/bits/floatn.h @@ -28,7 +28,8 @@ support, for x86_64 and x86. */ #if (defined __x86_64__ \ ? __GNUC_PREREQ (4, 3) \ - : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) + : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) \ + || defined __clang__ # define __HAVE_FLOAT128 1 #else # define __HAVE_FLOAT128 0 @@ -58,7 +59,9 @@ /* Defined to concatenate the literal suffix to be used with _Float128 types, if __HAVE_FLOAT128 is 1. */ # if __HAVE_FLOAT128 -# if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) +# if !__GNUC_PREREQ (7, 0) \ + || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) \ + || defined __clang__ /* The literal suffix f128 exists only since GCC 7.0. */ # define __f128(x) x##q # else @@ -68,7 +71,9 @@ /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */ # if __HAVE_FLOAT128 -# if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) +# if !__GNUC_PREREQ (7, 0) \ + || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) \ + || defined __clang__ /* Add a typedef for older GCC compilers which don't natively support _Complex _Float128. */ typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__))); @@ -82,12 +87,14 @@ typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__))); # if __HAVE_FLOAT128 /* The type _Float128 exists only since GCC 7.0. */ -# if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) +# if !__GNUC_PREREQ (7, 0) \ + || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) \ + || defined __clang__ typedef __float128 _Float128; # endif /* __builtin_huge_valf128 doesn't exist before GCC 7.0. */ -# if !__GNUC_PREREQ (7, 0) +# if !__GNUC_PREREQ (7, 0) && !defined __clang__ # define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ()) # endif @@ -96,7 +103,7 @@ typedef __float128 _Float128; Converting a narrower sNaN to _Float128 produces a quiet NaN, so attempts to use _Float128 sNaNs will not work properly with older compilers. */ -# if !__GNUC_PREREQ (7, 0) +# if !__GNUC_PREREQ (7, 0) && !defined __clang__ # define __builtin_copysignf128 __builtin_copysignq # define __builtin_fabsf128 __builtin_fabsq # define __builtin_inff128() ((_Float128) __builtin_inf ()) @@ -108,7 +115,7 @@ typedef __float128 _Float128; e.g.: __builtin_signbitf128, before GCC 6. However, there has never been a __builtin_signbitf128 in GCC and the type-generic builtin is only available since GCC 6. */ -# if !__GNUC_PREREQ (6, 0) +# if !__GNUC_PREREQ (6, 0) && !defined __clang__ # define __builtin_signbitf128 __signbitf128 # endif