From patchwork Wed May 17 18:08:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 95468 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1328041vqo; Wed, 17 May 2023 11:09:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Lw/JieLmk/xVvGhUqKfQOdZrxLW1DghLqTsdrM17oPKvWeHVRkSsNoAf+VBSSBHXFSJ20 X-Received: by 2002:a50:ef0e:0:b0:510:d6f5:3970 with SMTP id m14-20020a50ef0e000000b00510d6f53970mr1871525eds.32.1684346974714; Wed, 17 May 2023 11:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684346974; cv=none; d=google.com; s=arc-20160816; b=fQC+Yefn82LWRuvYyBJR3Aq2cpbvShsKa5YGxMiZpFN4e2J0HuaxU1pki50iAx43Ps z3fSRIFMG0WvQlk2A9g3X79SE2msRmVILu6YQFX/2pLwhGPD/1H3lu+iEuMcth7O4OyQ 3v0Sptq0f2oYMq1D2WHPlNZH3eYhbsDrdeNiDlFMuXs0VeEprHumEYJMRWlIa7OcMe6Q i9NFr5oNSMbwW2nEM7p6RRzrfc6wbKGiLb1fLB1quqSqX+cHZJQ4QKZGb1PJa8oyDAo4 xzGptXka+E8iLYdNWh+eeCO9BKL1FJQKe4YnpslZJjRVARxr1BtWlHtvGXcry1GSZ+Zy TLlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=LnB79Rv2JhozE+pijkzIPfBSYcXMQOFI43IqOG8My0g=; b=TUtnMj7g6IFZACe6r9idy7/rZL8JPdy+mTTgcDIyyEiGOZTpoKRlb3lvpZ+Ftcvkqv BGYMBYsr45dM8JcQei3nZpan9mOHo5Ti2aUfwF5d4ZH80XonbgXq2rdQy7fp23PzXdpT AyNhspk8vINDobs5Nsiif/6AZUuuRXHJJ5w7sjysxExalAZ68o7Xe1oJthjtqL4K178x TP/9kRW3uGyHFXSCkJTKG80gZL/MyWO8USk4KlPdkvyXyzwD9nRqw4MeBG7bT82PFaeP PMoOIdpGLJdtivvwJCdzXkokoniDo64VMcswUGugC/8gYvCw+3TRIRdbGivRjPioveHz iWfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="sDYBQ+/i"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f4-20020a05640214c400b00506965fc8c8si17060994edx.43.2023.05.17.11.09.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 11:09:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.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=@gcc.gnu.org header.s=default header.b="sDYBQ+/i"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 34AD038560AA for ; Wed, 17 May 2023 18:09:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34AD038560AA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684346973; bh=LnB79Rv2JhozE+pijkzIPfBSYcXMQOFI43IqOG8My0g=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=sDYBQ+/iZ1drNp4VTEWUWAwmJd/AgbfGrZzJW6F/6/GYYHNIaWpBGozgq3w3yA/X+ CEQTeaSnBho7na53SJoA91aClK2sZ8WZhhsjRSh/du1bHdzFJfSB7NdxgdcaIYZPUP +XmXyhick5vE9/jBegeRYpm3DpeDC2rLS6U+qHNw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C7036385702B for ; Wed, 17 May 2023 18:08:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C7036385702B Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-486-jykVJP8PN2SRtw5kwaikiw-1; Wed, 17 May 2023 14:08:35 -0400 X-MC-Unique: jykVJP8PN2SRtw5kwaikiw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F0E718A6467; Wed, 17 May 2023 18:08:35 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 515702166B31; Wed, 17 May 2023 18:08:35 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 34HI8WfA609124 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 May 2023 20:08:33 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 34HI8WBe609123; Wed, 17 May 2023 20:08:32 +0200 Date: Wed, 17 May 2023 20:08:31 +0200 To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix up types in __builtin_{inf,huge_val,nan{,s},fabs,copysign}q builtins [PR109884] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766165812844627689?= X-GMAIL-MSGID: =?utf-8?q?1766165812844627689?= Hi! When _Float128 support has been added to C++ for 13.1, float128t_type_node tree has been added - in C float128_type_node and float128t_type_node is the same and represents both _Float128 and __float128, but in C++ they are distinct types which have different handling in the FEs. When doing that change, I mistakenly forgot to change FLOAT128 primitive type, which is used for the __builtin_{inf,huge_val,nan{,s},fabs,copysign}q builtins results and some of their arguments (and nothing else). The following patch fixes that. On ia64 we already use float128t_type_node for those builtins, pa while it has __float128 that type is the same as long double and so those builtins have long double types and on powerpc seems we don't have these builtins but instead define macros which map them to __builtin_*f128. That will not work properly in C++, perhaps we should change those macros to be function-like and cast to __float128. Anyway, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and 13.2? 2023-05-17 Jakub Jelinek PR c++/109884 * config/i386/i386-builtin-types.def (FLOAT128): Use float128t_type_node rather than float128_type_node. * c-c++-common/pr109884.c: New test. Jakub --- gcc/config/i386/i386-builtin-types.def.jj 2022-11-28 22:25:15.838734978 +0100 +++ gcc/config/i386/i386-builtin-types.def 2023-05-17 10:24:04.297929428 +0200 @@ -73,7 +73,7 @@ DEF_PRIMITIVE_TYPE (BFLOAT16, ix86_bf16_ DEF_PRIMITIVE_TYPE (FLOAT, float_type_node) DEF_PRIMITIVE_TYPE (DOUBLE, double_type_node) DEF_PRIMITIVE_TYPE (FLOAT80, float80_type_node) -DEF_PRIMITIVE_TYPE (FLOAT128, float128_type_node) +DEF_PRIMITIVE_TYPE (FLOAT128, float128t_type_node) DEF_PRIMITIVE_TYPE (CONST_STRING, const_string_type_node) # MMX vectors --- gcc/testsuite/c-c++-common/pr109884.c.jj 2023-05-17 10:41:42.295838862 +0200 +++ gcc/testsuite/c-c++-common/pr109884.c 2023-05-17 10:56:51.731872318 +0200 @@ -0,0 +1,32 @@ +/* PR c++/109884 */ +/* PowerPC doesn't define these as builtins, but macros expanding to + *f128 builtins. */ +/* { dg-do compile { target { __float128 && { { c || c++11 } && { ! powerpc*-*-* } } } } } */ +/* { dg-add-options __float128 } */ + +#ifdef __cplusplus +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; +#define HAS_TYPE(E, U) static_assert (is_same ::value, "") +#else +#define HAS_TYPE(E, U) _Static_assert (_Generic (E, default : 0, U : 1), "") +#endif + +void +foo () +{ + __float128 a = 0; + HAS_TYPE (__builtin_infq (), __float128); + HAS_TYPE (__builtin_huge_valq (), __float128); + HAS_TYPE (__builtin_nanq (""), __float128); + HAS_TYPE (__builtin_nansq (""), __float128); + HAS_TYPE (__builtin_fabsq (a), __float128); + HAS_TYPE (__builtin_copysignq (a, a), __float128); +}