From patchwork Mon Dec 19 08:11:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 34453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2314374wrn; Mon, 19 Dec 2022 02:48:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf4z1ryR6bWMor4gZq/fnqE48SvAnG877Lh4svQZB7GZ9Nymbaouh3xAX/hxTvvYAiCfJ3EQ X-Received: by 2002:a17:906:fcd8:b0:7c0:b66b:9ec0 with SMTP id qx24-20020a170906fcd800b007c0b66b9ec0mr32276393ejb.16.1671446922891; Mon, 19 Dec 2022 02:48:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671446922; cv=none; d=google.com; s=arc-20160816; b=A/y6m1C8xLdLqp4UvI57WpdSHrwhFyc6CGmXkfbrJJ4beyD55TT8D+blqxEi9BU1zb 2Xvi7z9UfyK5apFrim107Bl73etpRkjqxSS3c8anFzD2c8GV73CTvQX0QRie2HhT6j7W W4POaYY3ri11mSZlJqx0MdAWiUHcxC8ADdH0Wfc9cKlG9dQZIbJyF/HJn2JmWXtMI285 HjoygGwhaTUm+fT6mHEgaQxWvBKd56oIABCMX7jOCHOKy9dkWPE+Iq5A29zfqdyQhJV8 DUGgz+NZ7xQ9xiH6V1GMkcUIBV95ukiUkW08WWjAcRztK3vRnUyiROorY9B3FqCmBLJ8 H4hw== 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:mime-version :content-transfer-encoding:cc:to:subject:content-language:user-agent :date:message-id:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=h9untzJb3xJZ4aH4kcqYb00P3yd+U8wquyxteGvhrow=; b=c5OaIn9m/6IYoFKEHsDGKXjnKvEBwfy9wrcQSEKtS8Mh5S5HjoR34BfKJAytpUjvOb i28sEAf/rg/rNSzmmHnkxUxXXOdiZVgcCN6nTYYi3Q1lVenjdtA+0hHt+sUKEBd2y9Ev yCCeO3gT5zWf4fbV2WCG7B0493K88hRL8JlwXE0HntaNWjrOkymWhs4A8uu8+64/hZCl wTHvDdL7CPoZ0pIgWCDm5eo0golhX11L9lxv+tAbMkyYBAmrwC85gYfpfqGJT3lnG5kP rhx2lpnDaJIS48TQK8FfxtUwSyTz0frkaakhT78Jx+0cWBJIviAvogB77Ung+vCsVdZ7 O42Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=jyfA76Tv; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id xg1-20020a170907320100b007c10a0c31a3si7807841ejb.425.2022.12.19.02.48.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 02:48:42 -0800 (PST) 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=jyfA76Tv; 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 AD4533909982 for ; Mon, 19 Dec 2022 08:31:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD4533909982 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671438660; bh=h9untzJb3xJZ4aH4kcqYb00P3yd+U8wquyxteGvhrow=; h=Date:Subject:To:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=jyfA76TvlZBjKz2Ot3CVGK52QPbuUevzvCjZYHJ77A5xN+WvJLfMiUwn/POH5W7D6 FRedMKNQOWlSqPs5jg3rRFfKomGEEx+nNy6NEL7d6O1ey4HENa+Y1fkOTGlbVpgM14 tGs4WdgI8AuRbH/+i2vUwE1o4b9GWoREuu84RP2A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 052AC3D9F31B for ; Mon, 19 Dec 2022 08:12:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 052AC3D9F31B Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BJ7jreS021934; Mon, 19 Dec 2022 08:12:10 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3mjkuurt8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Dec 2022 08:12:10 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2BJ7kA9r022543; Mon, 19 Dec 2022 08:12:09 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3mjkuurt6r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Dec 2022 08:12:09 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2BJ2O5K7025317; Mon, 19 Dec 2022 08:12:07 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3mh6ywj2wm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Dec 2022 08:12:07 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2BJ8C3NF35586452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Dec 2022 08:12:04 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 673952004B; Mon, 19 Dec 2022 08:12:03 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E95B720040; Mon, 19 Dec 2022 08:12:00 +0000 (GMT) Received: from [9.197.234.5] (unknown [9.197.234.5]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 19 Dec 2022 08:12:00 +0000 (GMT) Message-ID: Date: Mon, 19 Dec 2022 16:11:59 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US Subject: [PATCH] fold-const: Treat fp conversion to a type with same mode as copy To: GCC Patches Cc: Richard Biener , Segher Boessenkool , Jakub Jelinek , Joseph Myers , Michael Meissner X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: YhOqTd7VoU4OlNXYWNwKvzQ58MymOPN4 X-Proofpoint-GUID: 8q0llqZ5EIMME9mXLoxL97r1RUbR_PpH X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-18_13,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 suspectscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212190070 X-Spam-Status: No, score=-11.2 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_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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" 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?1752639128881910998?= X-GMAIL-MSGID: =?utf-8?q?1752639128881910998?= Hi, In function fold_convert_const_real_from_real, when the modes of two types involved in fp conversion are the same, we can simply take it as copy, rebuild with the exactly same TREE_REAL_CST and the target type. It is more efficient and helps to avoid possible unexpected signalling bit clearing in [1]. Bootstrapped and regtested on x86_64-redhat-linux, aarch64-linux-gnu and powerpc64{,le}-linux-gnu. Is it ok for trunk? [1] https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608533.html gcc/ChangeLog: * fold-const.cc (fold_convert_const_real_from_real): Treat floating point conversion to a type with same mode as copy instead of normal convertFormat. --- gcc/fold-const.cc | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.27.0 diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 114258fa182..eb4b6ca8820 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -2178,6 +2178,15 @@ fold_convert_const_real_from_real (tree type, const_tree arg1) REAL_VALUE_TYPE value; tree t; + /* If the underlying modes are the same, simply treat it as + copy and rebuild with TREE_REAL_CST information and the + given type. */ + if (TYPE_MODE (type) == TYPE_MODE (TREE_TYPE (arg1))) + { + t = build_real (type, TREE_REAL_CST (arg1)); + return t; + } + /* Don't perform the operation if flag_signaling_nans is on and the operand is a signaling NaN. */ if (HONOR_SNANS (arg1)