From patchwork Fri Oct 21 07:23:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 6537 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp540645wrr; Fri, 21 Oct 2022 00:24:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4h1h3qdpDPVmtEBvb5LJpBOvqnjmKstYt0rjpsMa1Zaxv7weHAnHcoltqY8T4aRRpda23p X-Received: by 2002:a17:907:763b:b0:78d:ed3d:5a8 with SMTP id jy27-20020a170907763b00b0078ded3d05a8mr14195675ejc.132.1666337050381; Fri, 21 Oct 2022 00:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666337050; cv=none; d=google.com; s=arc-20160816; b=URgfwY7AUXiV49ZzC0QqE0SKGoc0DyDxJm9+zk3vp3sXqSH6puyH16yx+iP0jciFc6 f+LNh36f9FWx6LUY6pF/UWUVjNkPS9cGYu4ioM0IkVQ3urvasVrDLPSW8MUZIK9Y4EEl I5tahGR9jv2I43SCkd1OEn4Tm8HQY9lP2Ks2O+AbeN+nTGJ/5Zt/iAgw4kmoqwWtKejC ty/EdeXM9ka+aQxkVDDz1O9tsFoieSZL9KCHnT3pWeqLTWi5fkIlWsoCZTTy8j83zisc H25rAqIl8lOz3UVyGlf6frzlOlFuAkYOxlGJd76/oXN7d9PBOcWT36OB+3PILUefgpgl Xz5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=oEFVHSjmft/+SRhi+moArD/eKcz2YqvTPrUf0f3kI5s=; b=vqH+5laFlI+v50dhAgfxl6Rx2AsK9z05hlN7SP4XoUBaTT+7GP7idsZ46TBrORHIE1 qoBvHr6H802+51g/VELVJHe3qf947UMcQqEv7CwPug5D5Zi1VUATpUIOCoY87tXS7OYp GoRVlxeu341r530FbUCxg1vh0NFQ/C0gAg6y54VEYRvCuKygPmoesGINwBD5tWYgQTzN YFvj34jC9yv3nlj8EuRfRHTBT/ucdTedm2PtHUIyg+0sdW9xcWykwkGfOJdNAHYFLH7/ rVuAW5lgf40sAfKBNaJnvFt2faoeaR4C5BfXS8BRWZ1XUMRio2FBF1jHZiWE+mTyx5LA s3bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fWbrtVqy; 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 x14-20020a05640226ce00b0045cfb63a033si21813830edd.551.2022.10.21.00.24.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:24:10 -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=fWbrtVqy; 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 31EA6385737D for ; Fri, 21 Oct 2022 07:24:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31EA6385737D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666337049; bh=oEFVHSjmft/+SRhi+moArD/eKcz2YqvTPrUf0f3kI5s=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=fWbrtVqyuFlRbCpEXmcHivLESJF/K+sJJgRNbsn+gKIx1L2CEesDsuY2R1qgmoPc8 odU8hazpVWyEXCdBg888i0rhGHruqhuBr0ZlKPrhA3tqfnNqrZ+uTTDxJ3TlmkTqCE jY5WnSs0aaa0VbO7CBoJRnmtWKmNLz2p8rpbkNWM= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 54C0C385700C for ; Fri, 21 Oct 2022 07:23:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 54C0C385700C 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-85-EKqWttj4MGmf6ET6PWLllQ-1; Fri, 21 Oct 2022 03:23:23 -0400 X-MC-Unique: EKqWttj4MGmf6ET6PWLllQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 242CB8027EC; Fri, 21 Oct 2022 07:23:23 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D481D140EBF3; Fri, 21 Oct 2022 07:23:22 +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 29L7NJCf3484825 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Oct 2022 09:23:20 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 29L7NI6Y3484824; Fri, 21 Oct 2022 09:23:18 +0200 Date: Fri, 21 Oct 2022 09:23:17 +0200 To: "Joseph S. Myers" , Richard Biener , Jeff Law Subject: [PATCH] builtins: Add __builtin_nextafterf16b builtin Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: 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 Cc: Jonathan Wakely , gcc-patches@gcc.gnu.org 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?1747281038974269270?= X-GMAIL-MSGID: =?utf-8?q?1747281038974269270?= Hi! On top of the pending https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603665.html patch, the following patch adds another needed builtin. The above patch adds among other things __builtin_nextafterf16 builtin which we need in order to constexpr evaluate std::nextafter(_Float16) overload (patch for that to be posted momentarily). While there is inline implementation of the overload, it isn't constant evaluation friendly, and the builtin doesn't need libm implementation because it will be used only during constant expression evaluation. We need the same thing also for std::nextafter(__gnu_cxx::__bfloat16_t) though and this patch does that. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-10-21 Jakub Jelinek * builtin-types.def (BT_FN_BFLOAT16_BFLOAT16_BFLOAT16): New. * builtins.def (BUILT_IN_NEXTAFTERF16B): New builtin. * fold-const-call.cc (fold_const_call_sss): Handle CFN_BUILT_IN_NEXTAFTERF16B. Jakub --- gcc/builtin-types.def.jj 2022-10-20 16:43:03.031928876 +0200 +++ gcc/builtin-types.def 2022-10-20 16:44:15.768934809 +0200 @@ -461,6 +461,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT64X_FLOA BT_FLOAT64X, BT_FLOAT64X, BT_FLOAT64X) DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT128X_FLOAT128X_FLOAT128X, BT_FLOAT128X, BT_FLOAT128X, BT_FLOAT128X) +DEF_FUNCTION_TYPE_2 (BT_FN_BFLOAT16_BFLOAT16_BFLOAT16, + BT_BFLOAT16, BT_BFLOAT16, BT_BFLOAT16) DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT_FLOAT_FLOATPTR, BT_FLOAT, BT_FLOAT, BT_FLOAT_PTR) DEF_FUNCTION_TYPE_2 (BT_FN_DOUBLE_DOUBLE_DOUBLEPTR, --- gcc/builtins.def.jj 2022-10-20 16:43:03.033928849 +0200 +++ gcc/builtins.def 2022-10-20 16:46:27.467135944 +0200 @@ -591,6 +591,7 @@ DEF_C99_BUILTIN (BUILT_IN_NEXTAFT DEF_C99_BUILTIN (BUILT_IN_NEXTAFTERL, "nextafterl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_ERRNO) #define NEXTAFTER_TYPE(F) BT_FN_##F##_##F##_##F DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_NEXTAFTER, "nextafter", NEXTAFTER_TYPE, ATTR_MATHFN_ERRNO) +DEF_GCC_BUILTIN (BUILT_IN_NEXTAFTERF16B, "nextafterf16b", BT_FN_BFLOAT16_BFLOAT16_BFLOAT16, ATTR_MATHFN_ERRNO) DEF_C99_BUILTIN (BUILT_IN_NEXTTOWARD, "nexttoward", BT_FN_DOUBLE_DOUBLE_LONGDOUBLE, ATTR_MATHFN_ERRNO) DEF_C99_BUILTIN (BUILT_IN_NEXTTOWARDF, "nexttowardf", BT_FN_FLOAT_FLOAT_LONGDOUBLE, ATTR_MATHFN_ERRNO) DEF_C99_BUILTIN (BUILT_IN_NEXTTOWARDL, "nexttowardl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_ERRNO) --- gcc/fold-const-call.cc.jj 2022-10-20 16:43:03.033928849 +0200 +++ gcc/fold-const-call.cc 2022-10-20 16:50:14.300038009 +0200 @@ -1438,6 +1438,7 @@ fold_const_call_sss (real_value *result, CASE_CFN_NEXTAFTER: CASE_CFN_NEXTAFTER_FN: + case CFN_BUILT_IN_NEXTAFTERF16B: CASE_CFN_NEXTTOWARD: return fold_const_nextafter (result, arg0, arg1, format);