From patchwork Tue May 2 15:52:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 89407 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp718156vqo; Tue, 2 May 2023 08:54:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7yqeQFeE4WFoK3WNJBzK9k2d8FmnWAqFoYxw3DFdTNJH4msvBE/pQUK0MnkaeSuE5Zab/S X-Received: by 2002:aa7:df84:0:b0:50b:d57c:2a7c with SMTP id b4-20020aa7df84000000b0050bd57c2a7cmr1475551edy.18.1683042839854; Tue, 02 May 2023 08:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683042839; cv=none; d=google.com; s=arc-20160816; b=vX/VIqu8vkH8qImg6M68AmzQORECUOAydVeRMS3goCEY23icWlZ8QBBJZh6aUZD9uK M+kcpYik4zkMwiZgeTxBaqU1Iibd43+6iQCBd8kxoGubFs7PbeV4Ko0if7RTmRvj8i92 40Vz68iBv4Jg2SI76L1XyRTkBU5Fmpjcu1NjMtjTQu3TDsRptDdIUgodsUg6PoI5Q/r/ +cGEdwprhHpAsrEirer94vIFZ1ONAH6DPSAIdOp3NkzCj643DYjl2eAoDHIT/Ns/CczF mYSLtE1MmsRy3AxhatLT0uYGoF5uNckkAylTpD/CL/rNNfGrOeAklm/SEH0dwMtYBFd7 plDQ== 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-transfer-encoding:mime-version:date:cc:to:subject :message-id:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=jVowmsPmLIH/7nAd7FlW4rQYIP5n3bGADRMdhNWkT9g=; b=rpS6uFoF2soyhLH8xb+PbTfd9Dq7BjQyTX4HdIHvKcke1vX5pz4A2QAajTx4A/qm3C uOrxnL1rJstZb0hpHPfgvirlhAJpR3mC8fvQ4urxUNg7b8VpJiHxS3PpuguwBQLR+YCI 3vso9KuzI5AemkA7A4SpT/ffpBXlGuOVqQvJN4cCI20RBlCao8G+g8XUPY3E8x7vztLc 8l3vXd9CS16J3BRcw/GnpqqpxjhHVv93IEGvBHyOA5T9q5SvfNdraKZz0C+urDaVLxST +Rg17fzWDIn5YjJT2n6htDVzzl+powzh0Z+JgnXTQmoG7rx+qze0x2Jb9n7Kg9l74kil UNYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=biSNpsbZ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id m18-20020aa7d352000000b00506b1652facsi25101709edr.393.2023.05.02.08.53.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 08:53:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=biSNpsbZ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 24876385771A for ; Tue, 2 May 2023 15:53:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24876385771A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683042832; bh=jVowmsPmLIH/7nAd7FlW4rQYIP5n3bGADRMdhNWkT9g=; h=Subject:To:Cc:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=biSNpsbZPQmRgcy6wgV4gtepJ2nuYOTIJgVyQpt/n4Zn5yQ3zPqFtJYGeOGIRn7gu 0l8WXu3pan9oQfR7afUXmW6x4CgCjZn2r4oCwUSo8QtXN07pLPDbbFXcmdkYAlr+7w YyuhmDBEktnkwx8ew6CDMxMJiNq72Y32jHWgBIfI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 522263857014 for ; Tue, 2 May 2023 15:52:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 522263857014 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 342FnjWo020491; Tue, 2 May 2023 15:52:24 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qb4aau1cg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 May 2023 15:52:23 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 342FANiO002650; Tue, 2 May 2023 15:52:22 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([9.208.129.113]) by ppma02wdc.us.ibm.com (PPS) with ESMTPS id 3q8tv8846v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 May 2023 15:52:21 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 342FqKBe30277944 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 May 2023 15:52:20 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCC3858056; Tue, 2 May 2023 15:52:19 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82EE45805A; Tue, 2 May 2023 15:52:19 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.163.52.55]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 2 May 2023 15:52:19 +0000 (GMT) Message-ID: Subject: [PATCH] rs6000: Add builtins for IEEE 128-bit floating point values To: Segher Boessenkool , gcc-patches@gcc.gnu.org Cc: cel@us.ibm.com, Peter Bergner Date: Tue, 02 May 2023 08:52:19 -0700 X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: gQmH_i_TC8F3rL-g0MKp8J8bq1Y8UEuw X-Proofpoint-ORIG-GUID: gQmH_i_TC8F3rL-g0MKp8J8bq1Y8UEuw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-02_10,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 impostorscore=0 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=945 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305020133 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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: Carl Love via Gcc-patches From: Carl Love Reply-To: Carl Love 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?1764798328799831686?= X-GMAIL-MSGID: =?utf-8?q?1764798328799831686?= GCC maintainers: The following patch adds three buitins for inserting and extracting the exponent and significand for an IEEE 128-bit floating point values. The builtins are valid for Power 9 and Power 10. The patch has been tested on both Power 9 and Power 10. Please let me know if this patch is acceptable for mainline. Thanks. Carl ---------------------- From a20cc81f98cce1140fc95775a7c25b55d1ca7cba Mon Sep 17 00:00:00 2001 From: Carl Love Date: Wed, 12 Apr 2023 17:46:37 -0400 Subject: [PATCH] rs6000: Add builtins for IEEE 128-bit floating point values Add support for the following builtins: __vector unsigned long long int __builtin_extractf128_exp (__ieee128); __vector unsigned __int128 __builtin_extractf128_sig (__ieee128); __ieee128 __builtin_insertf128_exp (__vector unsigned __int128, __vector unsigned long long); gcc/ * config/rs6000/rs6000-buildin.def (__builtin_extractf128_exp, __builtin_extractf128_sig, __builtin_insertf128_exp): Add new builtin definitions. * config/rs6000.md (extractf128_exp_, insertf128_exp_, extractf128_sig_): Add define_expand for new builtins. (xsxexpqp_f128_, xsxsigqp_f128_, siexpqpf_f128_): Add define_insn for new builtins. * doc/extend.texi (__builtin_extractf128_exp, __builtin_extractf128_sig, __builtin_insertf128_exp): Add documentation for new builtins. gcc/testsuite/ * gcc.target/powerpc/bfp/extract-exp-ieee128.c: New test case. * gcc.target/powerpc/bfp/extract-sig-ieee128.c: New test case. * gcc.target/powerpc/bfp/insert-exp-ieee128.c: New test case. --- gcc/config/rs6000/rs6000-builtins.def | 9 +++ gcc/config/rs6000/vsx.md | 66 ++++++++++++++++++- gcc/doc/extend.texi | 28 ++++++++ .../powerpc/bfp/extract-exp-ieee128.c | 49 ++++++++++++++ .../powerpc/bfp/extract-sig-ieee128.c | 56 ++++++++++++++++ .../powerpc/bfp/insert-exp-ieee128.c | 58 ++++++++++++++++ 6 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/bfp/extract-exp-ieee128.c create mode 100644 gcc/testsuite/gcc.target/powerpc/bfp/extract-sig-ieee128.c create mode 100644 gcc/testsuite/gcc.target/powerpc/bfp/insert-exp-ieee128.c diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index 638d0bc72ca..3247a7f7673 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -2876,6 +2876,15 @@ pure vsc __builtin_vsx_xl_len_r (void *, signed long); XL_LEN_R xl_len_r {} + vull __builtin_extractf128_exp (_Float128); + EEXPKF extractf128_exp_kf {} + + vuq __builtin_extractf128_sig (_Float128); + ESIGKF extractf128_sig_kf {} + + _Float128 __builtin_insertf128_exp (vuq, vull); + IEXPKF_VULL insertf128_exp_kf {} + ; Builtins requiring hardware support for IEEE-128 floating-point. [ieee128-hw] diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index 7d845df5c2d..2a9f875ba57 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -369,7 +369,10 @@ UNSPEC_XXSPLTI32DX UNSPEC_XXBLEND UNSPEC_XXPERMX - ]) + UNSPEC_EXTRACTEXPIEEE + UNSPEC_EXTRACTSIGIEEE + UNSPEC_INSERTEXPIEEE +]) (define_int_iterator XVCVBF16 [UNSPEC_VSX_XVCVSPBF16 UNSPEC_VSX_XVCVBF16SPN]) @@ -4155,6 +4158,38 @@ "vinsrx %0,%1,%2" [(set_attr "type" "vecsimple")]) +(define_expand "extractf128_exp_" + [(set (match_operand:V2DI 0 "altivec_register_operand") + (unspec:IEEE128 [(match_operand:IEEE128 1 "altivec_register_operand")] + UNSPEC_EXTRACTEXPIEEE))] +"TARGET_P9_VECTOR" +{ + emit_insn (gen_xsxexpqp_f128_ (operands[0], operands[1])); + DONE; +}) + +(define_expand "insertf128_exp_" + [(set (match_operand:IEEE128 0 "altivec_register_operand") + (unspec:IEEE128 [(match_operand:V1TI 1 "altivec_register_operand") + (match_operand:V2DI 2 "altivec_register_operand")] + UNSPEC_INSERTEXPIEEE))] +"TARGET_P9_VECTOR" +{ + emit_insn (gen_xsiexpqpf_f128_ (operands[0], operands[1], + operands[2])); + DONE; +}) + +(define_expand "extractf128_sig_" + [(set (match_operand:V2DI 0 "altivec_register_operand") + (unspec:IEEE128 [(match_operand:IEEE128 1 "altivec_register_operand")] + UNSPEC_EXTRACTSIGIEEE))] +"TARGET_P9_VECTOR" +{ + emit_insn (gen_xsxsigqp_f128_ (operands[0], operands[1])); + DONE; +}) + (define_expand "vreplace_elt_" [(set (match_operand:REPLACE_ELT 0 "register_operand") (unspec:REPLACE_ELT [(match_operand:REPLACE_ELT 1 "register_operand") @@ -5016,6 +5051,15 @@ "xsxexpqp %0,%1" [(set_attr "type" "vecmove")]) +;; VSX Scalar to Vector Extract Exponent IEEE 128-bit floating point format +(define_insn "xsxexpqp_f128_" + [(set (match_operand:V2DI 0 "altivec_register_operand" "=v") + (unspec:V2DI [(match_operand:IEEE128 1 "altivec_register_operand" "v")] + UNSPEC_VSX_SXEXPDP))] + "TARGET_P9_VECTOR" + "xsxexpqp %0,%1" + [(set_attr "type" "vecmove")]) + ;; VSX Scalar Extract Exponent Double-Precision (define_insn "xsxexpdp" [(set (match_operand:DI 0 "register_operand" "=r") @@ -5034,6 +5078,15 @@ "xsxsigqp %0,%1" [(set_attr "type" "vecmove")]) +;; VSX Scalar to Vector Extract Significand IEEE 128-bit floating point format +(define_insn "xsxsigqp_f128_" + [(set (match_operand:V2DI 0 "altivec_register_operand" "=v") + (unspec:V2DI [(match_operand:IEEE128 1 "altivec_register_operand" "v")] + UNSPEC_VSX_SXSIG))] + "TARGET_P9_VECTOR" + "xsxsigqp %0,%1" + [(set_attr "type" "vecmove")]) + ;; VSX Scalar Extract Significand Double-Precision (define_insn "xsxsigdp" [(set (match_operand:DI 0 "register_operand" "=r") @@ -5054,6 +5107,17 @@ "xsiexpqp %0,%1,%2" [(set_attr "type" "vecmove")]) +;; VSX Insert Exponent IEEE 128-bit Floating point format +(define_insn "xsiexpqpf_f128_" + [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v") + (unspec:IEEE128 + [(match_operand:V1TI 1 "altivec_register_operand" "v") + (match_operand:V2DI 2 "altivec_register_operand" "v")] + UNSPEC_VSX_SIEXPQP))] + "TARGET_P9_VECTOR" + "xsiexpqp %0,%1,%2" + [(set_attr "type" "vecmove")]) + ;; VSX Scalar Insert Exponent Quad-Precision (define_insn "xsiexpqp_" [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v") diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index e426a2eb7d8..456e5a03d69 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -18511,6 +18511,34 @@ the FPSCR. The instruction is a lower latency version of the @code{mffs} instruction. If the @code{mffsl} instruction is not available, then the builtin uses the older @code{mffs} instruction to read the FPSCR. +@smallexample +@exdent vector unsigned long long int +@exdent __builtin_extractf128_exp (__ieee128); +@end smallexample + +The exponent from the IEEE 128-bit floating point value is returned in the +lower bits of vector element 1 on Little Endian systems. + +@smallexample +@exdent vector unsigned __int128 +@exdent __builtin_extractf128_sig (__ieee128); +@end smallexample + +The significand from the IEEE 128-bit floating point value is returned in the +vector element 0 bits [111:0]. Bit 112 is set to 0 if the input value was zero +or Denormal, 1 otherwise. Bits [127:113] are set to zero. + +@smallexample +@exdent _ieee128 +@exdent __builtin_insertf128_exp (vector unsigned __int128, +vector unsigned long long int); +@end smallexample + +The first argument contains the significand in bits [111:0] for the IEEE +128-bi floating point tresult and the sign bit [127] for the result. The +second argument contains the exponenet bits for the result in bits [14:0] of +vector element 1. + @node Basic PowerPC Built-in Functions Available on ISA 3.1 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.1 diff --git a/gcc/testsuite/gcc.target/powerpc/bfp/extract-exp-ieee128.c b/gcc/testsuite/gcc.target/powerpc/bfp/extract-exp-ieee128.c new file mode 100644 index 00000000000..47e2c43962f --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/bfp/extract-exp-ieee128.c @@ -0,0 +1,49 @@ +/* { dg-do run { target { powerpc*-*-* } } } */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-mdejagnu-cpu=power9" } */ + +#include +#include + +#if DEBUG +#include +#endif + +vector unsigned long long int +get_exponents (__ieee128 *p) +{ + __ieee128 source = *p; + + return __builtin_extractf128_exp (source); +} + +int +main () +{ + vector unsigned long long int result, exp_result; + union conv128_t + { + __ieee128 val_ieee128; + __int128 val_int128; + } source; + + exp_result[0] = 0x0ULL; + exp_result[1] = 0x1234ULL; + source.val_int128 = 0x923456789ABCDEF0ULL; + source.val_int128 = (source.val_int128 << 64) | 0x123456789ABCDEFULL; + + result = get_exponents (&source.val_ieee128); + + if ((result[0] != exp_result[0]) || (result[1] != exp_result[1])) +#if DEBUG + { + printf("result[0] = 0x%llx; exp_result[0] = 0x%llx\n", + result[0], exp_result[0]); + printf("result[1] = 0x%llx; exp_result[1] = 0x%llx\n", + result[1], exp_result[1]); + } +#else + abort(); +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/bfp/extract-sig-ieee128.c b/gcc/testsuite/gcc.target/powerpc/bfp/extract-sig-ieee128.c new file mode 100644 index 00000000000..4bd50ca2281 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/bfp/extract-sig-ieee128.c @@ -0,0 +1,56 @@ +/* { dg-do run { target { powerpc*-*-* } } } */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-mdejagnu-cpu=power9" } */ + +#include +#include + +#if DEBUG +#include +#endif + +vector unsigned __int128 +get_significand (__ieee128 *p) +{ + __ieee128 source = *p; + + return __builtin_extractf128_sig (source); +} + +int +main () +{ + #define NOT_ZERO_OR_DENORMAL 0x1000000000000 + + union conv128_t + { + __ieee128 val_ieee128; + unsigned long long int val_ull[2]; + unsigned __int128 val_uint128; + __vector unsigned __int128 val_vuint128; + } source, result, exp_result; + + /* Result is not zero or denormal. */ + exp_result.val_ull[1] = 0x00056789ABCDEF0ULL | NOT_ZERO_OR_DENORMAL; + exp_result.val_ull[0] = 0x123456789ABCDEFULL; + source.val_uint128 = 0x923456789ABCDEF0ULL; + source.val_uint128 = (source.val_uint128 << 64) | 0x123456789ABCDEFULL; + + /* Note, bits[0:14] are set to 0, bit[15] is 0 if the input was zero or + Denormal, 1 otherwise. */ + result.val_vuint128 = get_significand (&source.val_ieee128); + + if ((result.val_ull[0] != exp_result.val_ull[0]) + || (result.val_ull[1] != exp_result.val_ull[1])) +#if DEBUG + { + printf("result[0] = 0x%llx; exp_result[0] = 0x%llx\n", + result.val_ull[0], exp_result.val_ull[0]); + printf("result[1] = 0x%llx; exp_result[1] = 0x%llx\n", + result.val_ull[1], exp_result.val_ull[1]); + } +#else + abort(); +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/bfp/insert-exp-ieee128.c b/gcc/testsuite/gcc.target/powerpc/bfp/insert-exp-ieee128.c new file mode 100644 index 00000000000..5bd33ed5b7d --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/bfp/insert-exp-ieee128.c @@ -0,0 +1,58 @@ +/* { dg-do run { target { powerpc*-*-* } } } */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-mdejagnu-cpu=power9" } */ + +#include +#include + +#ifdef DEBUG +#include +#endif + +__ieee128 +insert_exponent (__vector unsigned __int128 *significand_p, + __vector unsigned long long int *exponent_p) +{ + __vector unsigned __int128 significand = *significand_p; + __vector unsigned long long int exponent = *exponent_p; + + return __builtin_insertf128_exp (significand, exponent); +} + + +int +main () +{ + union conv128_t + { + __ieee128 val_ieee128; + __vector unsigned __int128 val_vint128; + __vector unsigned long long int val_vull; + } result, exp_result, significand; + + __vector unsigned long long int exponent; + + significand.val_vull[0] = 0xFEDCBA9876543210ULL; + significand.val_vull[1] = 0x7FFF12345678ABCDULL; /* positive value */ + + exponent[0] = 0x5678; + exponent[1] = 0x1234; + + exp_result.val_vull[0] = 0xFEDCBA9876543210ULL; + exp_result.val_vull[1] = 0x123412345678ABCDULL; + + result.val_ieee128 = insert_exponent(&significand.val_vint128, &exponent); + + if (result.val_ieee128 != exp_result.val_ieee128) +#ifdef DEBUG + { + printf("result.val_vull[0] = 0x%llx, exp_result.val_vull[0] = 0x%llx\n", + result.val_vull[0], exp_result.val_vull[0]); + printf("result.val_vull[1] = 0x%llx, exp_result.val_vull[1] = 0x%llx\n", + result.val_vull[1], exp_result.val_vull[1]); + } +#else + abort (); +#endif + +}