From patchwork Mon Aug 28 20:00:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 137077 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp3552064vqm; Mon, 28 Aug 2023 13:02:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqjKeU8h55F6HgFFO/bTQMJmu3lBfyCWa1Zs3aulcV9gdO/BD+QHzWsKjBeYdwynPlVXo9 X-Received: by 2002:a05:6402:164e:b0:523:ba10:d795 with SMTP id s14-20020a056402164e00b00523ba10d795mr21440203edx.11.1693252977678; Mon, 28 Aug 2023 13:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693252977; cv=none; d=google.com; s=arc-20160816; b=at7yEoY/hpzYhafDo1P9/Hm3VxIRS9JQKclo3Op4dy2xOcS0dPYDcLCVaW/1y05JB1 g/ea2DZEdM/2Ns65fW9F7cfHQIr/BZzKEQGnOZOcrH8qBjvXvzXNsG3SEKaORedWFGQd 9Gzw5Qi+JSeHMMhPM44p53c9hzyTy+/DRnM0a5HCOKfPn0xvkX5MxLNZUO5V/TTXqGWy aAowO5oQWfqs6LyCR8zGzIpTZYfphgiMZPCQ7HLjDJ5onDJv8laiepx42bmkEfcXVFwi dNhXSGTLaP2FVVLoCK9OBhOmwW3F91b266euNjfcxbQlOiuTWm2R35CtLdlKw3+R1lJY TtpA== 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-transfer-encoding:mime-version:date:to:subject:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=3VRN+Z6DJI6OK8pve0iyQuPLjLzXbJRk2B8o9Hp4PIE=; fh=JGOFsU87fLL6aCvenYxgsF+mgCiM/C4u0ejuUvMZn1g=; b=p/eW20B6BZ7Nwfkw3a3Ywxyas+AcYZ7elt/pRSc1+8n+RcBuxFXqXsZFxIaJr19ipQ +KOkOHO+UkrsidIFKZqh8+MSKyla86GNd4vb7iW4eNb3hEZnvsOf4r0toUniskk8lotA cBgPGISV0APZg4zk8quyAwD65ZT92Fvn3RF9IR1mFPKiNU75HXFTtrWZZsIrIa85CjUR leR5bqVgcPmPVxw9RgjN3foZOPR4BO2v/cKXCH/yCppLkVSNzKqhOY4Iyp2FeInuN8vq 8DA8Ql8QqjttAqP7T3O/Ejz7OXNgc7fDIJVa4BEdBX776t4q5l4VPRj3c9jITJ+qXBLn 26wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mPbk8QkN; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b12-20020aa7c6cc000000b00522789dbee0si2745875eds.204.2023.08.28.13.02.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 13:02:57 -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=mPbk8QkN; 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 C27263856DDC for ; Mon, 28 Aug 2023 20:01:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C27263856DDC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693252906; bh=3VRN+Z6DJI6OK8pve0iyQuPLjLzXbJRk2B8o9Hp4PIE=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=mPbk8QkNJwjdNxdXcTfbIRhU2okYq6Q4tj6/1BSZUKEf7m9duts0l3UD8TPp1Kbcw 5Y7KLYqBqTTSthXeq/hTeIfkSlDYeLJCGYXy0LVFik3jT6kRrZjs/EkFtU28JgLDsg swOCIQ/TfUnZa2OrkoDiZGuTnBOdCEQJISsmoHhc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 38AA6385773C for ; Mon, 28 Aug 2023 20:00:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38AA6385773C Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37SJaET8024071; Mon, 28 Aug 2023 20:00:54 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sr51u1vvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Aug 2023 20:00:53 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 37SK0I4K007321; Mon, 28 Aug 2023 20:00:53 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sr51u1vus-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Aug 2023 20:00:53 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37SIYBZJ009966; Mon, 28 Aug 2023 20:00:52 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sqw7k5qjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Aug 2023 20:00:52 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 37SK0oqW3539602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Aug 2023 20:00:50 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 722EB5805F; Mon, 28 Aug 2023 20:00:50 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4970058059; Mon, 28 Aug 2023 20:00:49 +0000 (GMT) Received: from wecm-9-67-137-54.wecm.ibm.com (unknown [9.67.137.54]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 28 Aug 2023 20:00:49 +0000 (GMT) Message-ID: <7b79bbc4c465d22e565ec627ed379575bf9f7cf5.camel@us.ibm.com> Subject: [PATCH ver 4] rs6000, add overloaded DFP quantize support To: "Kewen.Lin" , Segher Boessenkool , David Edelsohn , GCC Patches Date: Mon, 28 Aug 2023 13:00:48 -0700 X-Mailer: Evolution 3.28.5 (3.28.5-22.el8) Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 8tZUF2skkGPhGjCpskBEjXFWQ1_bjxhr X-Proofpoint-ORIG-GUID: ruOttWSX8_72CpYPUzsydb0bs5BX5EcP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-28_17,2023-08-28_04,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 impostorscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 spamscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308280170 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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.30 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 Cc: Peter Bergner Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775141513571662676 X-GMAIL-MSGID: 1775504433972664901 GCC maintainers: Version 4, additional define_insn name fix. Change Log fix for the UNSPEC_DQUAN. Retested patch on Power 10 LE. Version 3, fixed the built-in instance names. Missed removing the "n" the name. Added the tighter constraints on the predicates for the define_insn. Updated the wording for the built-ins in the documentation file. Changed the test file name again. Updated the ChangeLog file, added the PR target line. Retested the patch on Power 10LE and Power 8 and Power 9. Version 2, renamed the built-in instances. Changed the name of the overloaded built-in. Added the missing documentation for the new built-ins. Fixed typos. Changed name of the test. Updated the effective target for the test. Retested the patch on Power 10LE and Power 8 and Power 9. The following patch adds four built-ins for the decimal floating point (DFP) quantize instructions on rs6000. The built-ins are for 64-bit and 128-bit DFP operands. The patch also adds a test case for the new builtins. The Patch has been tested on Power 10LE and Power 9 LE/BE. Please let me know if the patch is acceptable for mainline. Thanks. Carl Love ---------------------------------------- rs6000, add overloaded DFP quantize support Add decimal floating point (DFP) quantize built-ins for both 64-bit DFP and 128-DFP operands. In each case, there is an immediate version and a variable version of the built-in. The RM value is a 2-bit constant int which specifies the rounding mode to use. For the immediate versions of the built-in, the TE field is a 5-bit constant that specifies the value of the ideal exponent for the result. The built-in specifications are: __Decimal64 builtin_dfp_quantize (_Decimal64, _Decimal64, const int RM) __Decimal64 builtin_dfp_quantize (const int TE, _Decimal64, const int RM) __Decimal128 builtin_dfp_quantize (_Decimal128, _Decimal128, const int RM) __Decimal128 builtin_dfp_quantize (const int TE, _Decimal128, const int RM) A testcase is added for the new built-in definitions. gcc/ChangeLog: * config/rs6000/dfp.md (UNSPEC_DQUAN): New unspec. (dfp_dqua_, dfp_dquai_): New define_insn. * config/rs6000/rs6000-builtins.def (__builtin_dfp_dqua, __builtin_dfp_dquai, __builtin_dfp_dquaq, __builtin_dfp_dquaqi): New buit-in definitions. * config/rs6000/rs6000-overload.def (__builtin_dfp_quantize): New overloaded definition. * doc/extend.texi: Add documentation for __builtin_dfp_quantize. gcc/testsuite/ * gcc.target/powerpc/pr93448.c: New test case. PR target/93448 --- gcc/config/rs6000/dfp.md | 25 ++- gcc/config/rs6000/rs6000-builtins.def | 15 ++ gcc/config/rs6000/rs6000-overload.def | 10 ++ gcc/doc/extend.texi | 17 ++ gcc/testsuite/gcc.target/powerpc/pr93448.c | 200 +++++++++++++++++++++ 5 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr93448.c diff --git a/gcc/config/rs6000/dfp.md b/gcc/config/rs6000/dfp.md index 5ed8a73ac51..bf4a227b0eb 100644 --- a/gcc/config/rs6000/dfp.md +++ b/gcc/config/rs6000/dfp.md @@ -271,7 +271,8 @@ (define_c_enum "unspec" UNSPEC_DIEX UNSPEC_DSCLI UNSPEC_DTSTSFI - UNSPEC_DSCRI]) + UNSPEC_DSCRI + UNSPEC_DQUAN]) (define_code_iterator DFP_TEST [eq lt gt unordered]) @@ -395,3 +396,25 @@ (define_insn "dfp_dscri_" "dscri %0,%1,%2" [(set_attr "type" "dfp") (set_attr "size" "")]) + +(define_insn "dfp_dqua_" + [(set (match_operand:DDTD 0 "gpc_reg_operand" "=d") + (unspec:DDTD [(match_operand:DDTD 1 "gpc_reg_operand" "d") + (match_operand:DDTD 2 "gpc_reg_operand" "d") + (match_operand:SI 3 "const_0_to_3_operand" "n")] + UNSPEC_DQUAN))] + "TARGET_DFP" + "dqua %0,%1,%2,%3" + [(set_attr "type" "dfp") + (set_attr "size" "")]) + +(define_insn "dfp_dquai_" + [(set (match_operand:DDTD 0 "gpc_reg_operand" "=d") + (unspec:DDTD [(match_operand:SI 1 "s5bit_cint_operand" "n") + (match_operand:DDTD 2 "gpc_reg_operand" "d") + (match_operand:SI 3 "const_0_to_3_operand" "n")] + UNSPEC_DQUAN))] + "TARGET_DFP" + "dquai %1,%0,%2,%3" + [(set_attr "type" "dfp") + (set_attr "size" "")]) diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index 8a294d6c934..ce40600e803 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -2983,6 +2983,21 @@ const unsigned long long __builtin_unpack_dec128 (_Decimal128, const int<1>); UNPACK_TD unpacktd {} + const _Decimal64 __builtin_dfp_dqua (_Decimal64, _Decimal64, \ + const int<2>); + DFPQUAN_64 dfp_dqua_dd {} + + const _Decimal64 __builtin_dfp_dquai (const int<5>, _Decimal64, \ + const int<2>); + DFPQUAN_64i dfp_dquai_dd {} + + const _Decimal128 __builtin_dfp_dquaq (_Decimal128, _Decimal128, \ + const int<2>); + DFPQUAN_128 dfp_dqua_td {} + + const _Decimal128 __builtin_dfp_dquaqi (const int<5>, _Decimal128, \ + const int<2>); + DFPQUAN_128i dfp_dquai_td {} [crypto] const vull __builtin_crypto_vcipher (vull, vull); diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def index b83946f5ad8..38d92fcf1f0 100644 --- a/gcc/config/rs6000/rs6000-overload.def +++ b/gcc/config/rs6000/rs6000-overload.def @@ -195,6 +195,16 @@ unsigned long long __builtin_cmpb (unsigned long long, unsigned long long); CMPB +[DFPQUAN, dfp_quantize, __builtin_dfp_quantize] + _Decimal64 __builtin_dfp_quantize (_Decimal64, _Decimal64, const int); + DFPQUAN_64 + _Decimal64 __builtin_dfp_quantize (const int, _Decimal64, const int); + DFPQUAN_64i + _Decimal128 __builtin_dfp_quantize (_Decimal128, _Decimal128, const int); + DFPQUAN_128 + _Decimal128 __builtin_dfp_quantize (const int, _Decimal128, const int); + DFPQUAN_128i + [VEC_ABS, vec_abs, __builtin_vec_abs] vsc __builtin_vec_abs (vsc); ABS_V16QI diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 73a997276cb..8d7a1116cd9 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -18566,6 +18566,23 @@ The builtin uses the ISA 3.0 instruction @code{mffscdrn} if available. Otherwise the builtin reads the FPSCR, masks the current decimal rounding mode bits out and OR's in the new value. +_Decimal64 __builtin_dfp_quantize (_Decimal64, _Decimal64, const int); +_Decimal64 __builtin_dfp_quantize (const int, _Decimal64, const int); +_Decimal128 __builtin_dfp_quantize (_Decimal128, _Decimal128, const int); +_Decimal128 __builtin_dfp_quantize (const int, _Decimal128, const int); + +The @code{__builtin_dfp_quantize} built-in, converts and rounds the second +argument to the form with the exponent as specified by the first +argument based on the rounding mode specified by the third argument. +If the first argument is a decimal floating point value, its exponent is used +for converting and rounding of the second argument. If the first argument is a +5-bit constant integer value, then the value specifies the exponent to be used +when rounding and converting the second argument. The third argument is a +two bit constant integer that specifies the rounding mode. The possible modes +are: 00 Round to nearest, ties to even; 01 Round toward 0; 10 Round to nearest, +ties away from 0; 11 Round according to DRN where DRN is the Decimal Floating +point field of the FPSCR. + @end smallexample The following functions require @option{-mhard-float}, diff --git a/gcc/testsuite/gcc.target/powerpc/pr93448.c b/gcc/testsuite/gcc.target/powerpc/pr93448.c new file mode 100644 index 00000000000..f9c388585d7 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr93448.c @@ -0,0 +1,200 @@ +/* { dg-do run } */ +/* { dg-require-effective-target dfp_hw} */ +/* { dg-require-effective-target has_arch_pwr6} */ +/* { dg-options "-mhard-float -O2 -save-temps" } */ + +/* Test the decimal floating point quantize built-ins. */ + +#define DEBUG 0 + +#ifdef DEBUG +#include +#endif +#include + +void abort (void); + +int main() +{ +#define IMM2 2 +#define IMM3 3 +#define IMM4 4 + + _Decimal64 srcA_dfp64, srcB_dfp64; + _Decimal64 result_dfp64; + _Decimal64 expected_result_dfp64; + _Decimal128 srcA_dfp128, srcB_dfp128; + _Decimal128 result_dfp128; + _Decimal128 expected_result_dfp128; + + /* Third argument of quantize built-ins is the rounding mode value (RMC). + + RMC Rounding Mode + 00 Round to nearest, ties to even + 01 Round toward 0 + 10 Round to nearest, ties toward 0 + 11 Round according to DRN */ + + + /* Tests for quantize with 64-bit DFP variable. */ + srcA_dfp64 = 100.0df; + srcB_dfp64 = 300.456789df; + expected_result_dfp64 = 300.5df; + + result_dfp64 = __builtin_dfp_quantize (srcA_dfp64, srcB_dfp64, 0x0); + + if (result_dfp64 != expected_result_dfp64) +#if DEBUG + printf("DFP 64-bit quantize of variable, RMC = 0 result does not match expected result\n"); +#else + abort(); +#endif + + srcA_dfp64 = 100.00df; + srcB_dfp64 = 300.456789df; + expected_result_dfp64 = 300.45df; + + result_dfp64 = __builtin_dfp_quantize (srcA_dfp64, srcB_dfp64, 0x1); + + if (result_dfp64 != expected_result_dfp64) +#if DEBUG + printf("DFP 64-bit quantize of variable, RMC = 1 result does not match expected result\n"); +#else + abort(); +#endif + + srcA_dfp64 = 100.001df; + srcB_dfp64 = 3001.456789df; + expected_result_dfp64 = 3001.457df; + + result_dfp64 = __builtin_dfp_quantize (srcA_dfp64, srcB_dfp64, 0x2); + + if (result_dfp64 != expected_result_dfp64) +#if DEBUG + printf("DFP 64-bit quantize of variable, RMC = 2 result does not match expected result\n"); +#else + abort(); +#endif + + /* Tests for 64-bit quantize with immediate value. */ + + srcB_dfp64 = 10.4567df; + expected_result_dfp64 = 000.0df; + + result_dfp64 = __builtin_dfp_quantize (IMM2, srcB_dfp64, 0x0); + + if (result_dfp64 != expected_result_dfp64) +#if DEBUG + printf("DFP 64-bit quantize immediate, RMC = 0 result does not match expected result\n"); +#else + abort(); +#endif + + srcB_dfp64 = 104567.891df; + expected_result_dfp64 = 100000.0df; + + result_dfp64 = __builtin_dfp_quantize (IMM4, srcB_dfp64, 0x1); + + if (result_dfp64 != expected_result_dfp64) +#if DEBUG + printf("DFP 64-bit quantize immediate, RMC = 1 result does not match expected result\n"); +#else + abort(); +#endif + + srcB_dfp64 = 109876.54321df; + expected_result_dfp64 = 109900.0df; + + result_dfp64 = __builtin_dfp_quantize (IMM2, srcB_dfp64, 0x2); + + if (result_dfp64 != expected_result_dfp64) +#if DEBUG + printf("DFP 64-bit quantize immediate, RMC = 2 result does not match expected result\n"); +#else + abort(); +#endif + + /* Tests for quantize 128-bit DFP variable. */ + srcA_dfp128 = 0.018df; + srcB_dfp128 = 50000.18345df; + expected_result_dfp128 = 50000.180df; + + result_dfp128 = __builtin_dfp_quantize (srcA_dfp128, srcB_dfp128, 0x0); + + if (result_dfp128 != expected_result_dfp128) +#if DEBUG + printf("DFP 128-bit quantize variable, RMC = 0 result does not match expected result\n"); +#else + abort(); +#endif + + srcA_dfp128 = 8.01df; + srcB_dfp128 = 50000.18345df; + expected_result_dfp128 = 50000.18df; + + result_dfp128 = __builtin_dfp_quantize (srcA_dfp128, srcB_dfp128, 0x1); + + if (result_dfp128 != expected_result_dfp128) +#if DEBUG + printf("DFP 128-bit quantize variable, RMC = 1 result does not match expected result\n"); +#else + abort(); +#endif + + srcA_dfp128 = 0.1234df; + srcB_dfp128 = 50000.18346789df; + expected_result_dfp128 = 50000.1800df; + + result_dfp128 = __builtin_dfp_quantize (srcA_dfp128, srcB_dfp128, 0x2); + + if (result_dfp128 != expected_result_dfp128) +#if DEBUG + printf("DFP 128-bit quantize variable, RMC = 2 result does not match expected result\n"); +#else + abort(); +#endif + + /* Tests for 128-bit quantize with immediate value. */ + srcB_dfp128 = 1234.18345df; + expected_result_dfp128 = 1200.0df; + + result_dfp128 = __builtin_dfp_quantize (IMM2, srcB_dfp128, 0x0); + + if (result_dfp128 != expected_result_dfp128) +#if DEBUG + printf("DFP 128-bit quantize immediate, RMC = 0 result does not match expected result\n"); +#else + abort(); +#endif + + srcB_dfp128 = 123456.18345df; + expected_result_dfp128 = 120000.0df; + + result_dfp128 = __builtin_dfp_quantize (IMM4, srcB_dfp128, 0x1); + + if (result_dfp128 != expected_result_dfp128) +#if DEBUG + printf("DFP 128-bit quantize immediate, RMC = 1 result does not match expected result\n"); +#else + abort(); +#endif + + srcB_dfp128 = 12361834.5df; + expected_result_dfp128 = 12362000.0df; + + result_dfp128 = __builtin_dfp_quantize (IMM3, srcB_dfp128, 0x2); + + if (result_dfp128 != expected_result_dfp128) +#if DEBUG + printf("DFP 128-bit quantize immediate, RMC = 2 result does not match expected result\n"); +#else + abort(); +#endif + + return 0; +} + +/* { dg-final { scan-assembler-times {\mdqua\M} 3 } } */ +/* { dg-final { scan-assembler-times {\mdquai\M} 3 } } */ +/* { dg-final { scan-assembler-times {\mdquaq\M} 3 } } */ +/* { dg-final { scan-assembler-times {\mdquaiq\M} 3 } } */