From patchwork Wed May 8 05:27:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1932785 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=bNuo1KGz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VZ3Zz13sDz20fc for ; Wed, 8 May 2024 15:28:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3123A3858D20 for ; Wed, 8 May 2024 05:28:25 +0000 (GMT) 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 9E3D13858D20; Wed, 8 May 2024 05:28:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E3D13858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9E3D13858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715146086; cv=none; b=A8SdVvBSmtZ+8FLn0XOtCVuflWRASafiuT1p2KltuFJt3p7sGiGqfhehonIXO7uywPLP20jvvFVqDEEpcZlam+gI11hmm3vumfFf9d2CeF1uWYGrT3AzWLzZqDI/aJNFs9xTT+VXuWj0qy94mKzP30wmLQR9l08UPf2BQoe1DJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715146086; c=relaxed/simple; bh=lS45AsKhGHpaTraPhKnyW/4gh3IK5aUEXbuGEdIoKQk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=nhpXrZXZXNLoUTgeaRrdoEZ7YTNSYfvpQ5MsNaOwsuevOvTG1rr9u/EwKUdEx57KBrsLVwxLRTBhy8wbRjG6GLZSwALYE06d7ULPXk648fy3Oi9XUkW/FCOxXr77t1I8nGrMHV4vgAxOW6Eha9OT6ugAR1tue+BvvsvW8jpa6P4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4485C16i006239; Wed, 8 May 2024 05:28:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : from : to : cc : references : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=nK77WcIfpzCoGiJVUwE2oLft9LfKvTHQWLED3MiuMDM=; b=bNuo1KGzH/9mE5mmlLog3VMpMAmfTdRzzttiowUDol5XohzJHI+wPUeclxCh80Q7fk0S jCboONyI5T9f/2tVXmjWQKeIPHi7rqvaehJeEeyH5ZJDmYvXq32XmXW/9JEV8TBy1zub uFtHjyZTxEFFHtqvLlkH8EyRNczxgRgCvZ6ny43OmG263bglN5G1vK2LuwE6xoDs3TXM gdHpOOF3fdSqUSg4Ke8cgY6DCYUbtoSj71ZYKStXYkbBf1xG80RLlIbHMgz15xR+Crkc CKUvIdJyUugy5tAA8AVxQgGrZg023hnTSiythDT+47KYv9dA+AdmcgTJ2hnmBEl+bVO8 YA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3y031q81gt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 May 2024 05:28:03 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4485S2Qm003848; Wed, 8 May 2024 05:28:03 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3y031q81gm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 May 2024 05:28:02 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 4484XQld009228; Wed, 8 May 2024 05:28:01 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xysht2v8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 May 2024 05:28:01 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4485RvAj56099326 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 8 May 2024 05:27:59 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C9B52004D; Wed, 8 May 2024 05:27:57 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36FE12004B; Wed, 8 May 2024 05:27:55 +0000 (GMT) Received: from [9.200.57.36] (unknown [9.200.57.36]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 8 May 2024 05:27:54 +0000 (GMT) Message-ID: Date: Wed, 8 May 2024 13:27:53 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: [PATCH 2/4] fortran: Teach get_real_kind_from_node for Power 128 fp modes [PR112993] Content-Language: en-US From: "Kewen.Lin" To: GCC Patches Cc: fortran@gcc.gnu.org, Jakub Jelinek , Segher Boessenkool , Peter Bergner , David Edelsohn References: <813e8433-0428-1854-c82c-fc0743368fa8@linux.ibm.com> In-Reply-To: <813e8433-0428-1854-c82c-fc0743368fa8@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: M_imSbmqaDPQ7SZ6FnIZ0C1sfeoU8duq X-Proofpoint-ORIG-GUID: JuXyK5lPY_gQhOgFq7vRfUog-AI2LZ5b X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-08_02,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 clxscore=1011 impostorscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405080039 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, Previously effective target fortran_real_c_float128 never passes on Power regardless of the default 128 long double is ibmlongdouble or ieeelongdouble. It's due to that TF mode is always used for kind 16 real, which has precision 127, while the node float128_type_node for c_float128 has 128 type precision, get_real_kind_from_node can't find a matching as it only checks gfc_real_kinds[i].mode_precision and type precision. With changing TFmode/IFmode/KFmode to have the same mode precision 128, now fortran_real_c_float12 can pass with ieeelongdouble enabled by default and test cases guarded with it get tested accordingly. But with ibmlongdouble enabled by default, since TFmode has precision 128 which is the same as type precision 128 of float128_type_node, get_real_kind_from_node considers kind for TFmode matches float128_type_node, but it's wrong as at this time point TFmode is with ibm extended format. So this patch is to teach get_real_kind_from_node to check one more field which can be differentiable from the underlying real format, it can avoid the unexpected matching when there more than one modes have the same precision. Bootstrapped and regress-tested on: - powerpc64-linux-gnu P8/P9 (with ibm128 by default) - powerpc64le-linux-gnu P9/P10 (with ibm128 by default) - powerpc64le-linux-gnu P9 (with ieee128 by default) BR, Kewen ----- PR target/112993 gcc/fortran/ChangeLog: * trans-types.cc (get_real_kind_from_node): Consider the case where more than one modes have the same precision. --- gcc/fortran/trans-types.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.39.1 diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index 676014e9b98..dd94ef77741 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -183,7 +183,21 @@ get_real_kind_from_node (tree type) for (i = 0; gfc_real_kinds[i].kind != 0; i++) if (gfc_real_kinds[i].mode_precision == TYPE_PRECISION (type)) - return gfc_real_kinds[i].kind; + { + /* On Power, we have three 128-bit scalar floating-point modes + and all of their types have 128 bit type precision, so we + should check underlying real format details further. */ +#if defined(HAVE_TFmode) && defined(HAVE_IFmode) && defined(HAVE_KFmode) + if (gfc_real_kinds[i].kind == 16) + { + machine_mode mode = TYPE_MODE (type); + const struct real_format *fmt = REAL_MODE_FORMAT (mode); + if (fmt->p != gfc_real_kinds[i].digits) + continue; + } +#endif + return gfc_real_kinds[i].kind; + } return -4; }