From patchwork Mon Jan 8 02:35:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 185795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp798888dyq; Sun, 7 Jan 2024 18:37:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHsqwSRLQjOeXJ3IN9hxy3VOgUlvJmQmndEmvdhNb4Tb5ITY9ANZSu6AlkqaQg7P5ZWneDv X-Received: by 2002:a05:6358:94a6:b0:175:55b1:d00a with SMTP id i38-20020a05635894a600b0017555b1d00amr3259709rwb.13.1704681444678; Sun, 07 Jan 2024 18:37:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704681444; cv=pass; d=google.com; s=arc-20160816; b=Cl9iyDrjDPsBfGCnRgHR5IvHLugg5nsuwu1arD0v2JdUb14TGjfHXAjoWwk4jSTCi3 hr+Xnda1zsikRsEl8H10rfaCh8neLbXmknM5sKR1aD4+3SEmU5PjnYOtr4Ytx3+GVZnB +A7TXT1DBLhn7+FOFJlr790SgitO3CHW8ShX+d3xj9plhxU51X3rtCbmS6lyetwdD2hA N9P+Pmvcgu3ebeiVZS8dWZk2rMv3gxvRJ27I9jQHIn3LVVx/78x0l48XbNnjrQmA49DH j1gLK8Mr0TbgRe/j2ZJDU4AHkm3lHPMZxEFQJ4Lq4n7ougiGmZl0ssXvN056h1BFAvl4 heYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=OJZEzEERBu+ygFcS841LAW/fuBepcAdSLhPfmamA2e0=; fh=56Razey7PN8+4oxaLi6Cva+1buxJVsi3MEeY+hNo6PU=; b=EvY8cz379/teRfk20WebesLlDSDz+xkWQm8YaiHHPpIQP3WDjvoYAv2b+4sJWMnS0p E3OJN0tGakiXLPfyUsX6XnSYVawUmOISEYD6b0FOJ/BYnQtg4ZCf50fCe4t0xPF9wL8Z /Ge0k3dZZNYr9qLlzdxxC+QnNrbBOwzBekNZ0wNRcFdRwpIxFk8wCtOtftuqfednZ1iG 9aTBto/KSghGamALn/bZ+ivroC9J0zI8BAyUF8ENS6G0bxuPfZkEMWvjKY6Kl/ZMtTv6 sQM3RxSlngM3ghEoXRlb3H8vgVwNDYuIN/Q4TYgkVEa2ZSOxLKiKQXQ+EYkPJq4xvqkV aykg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=LIWMjn2V; arc=pass (i=1); 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e17-20020ac85dd1000000b0042979e0abd6si6085889qtx.724.2024.01.07.18.37.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 18:37:24 -0800 (PST) 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=@ibm.com header.s=pp1 header.b=LIWMjn2V; arc=pass (i=1); 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5C80038582A6 for ; Mon, 8 Jan 2024 02:37:24 +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 13978385803E for ; Mon, 8 Jan 2024 02:36:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13978385803E 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 13978385803E 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=1704681369; cv=none; b=ErgaqVPTyTzYj3+VdZLgOjpa0myy98aU0b8fRJJ+Y6VS3MIR+meYxgDlOrsK9rVHjy0LG7V6iTr9kyLU45a9dpYbO1Q4S3QycOwrzuN8OPERj6K3tBGYA/iBSGWPLyTvDD3hlZz/sPLjPwXKv9CujcwGXeXUq1oiw9d4vTv+JuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704681369; c=relaxed/simple; bh=1St8BDJKIlJ7VyY2hfcq8T+0yRW8rw9SrgDE5ljVfts=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=gpRCtHZ8qpuNnxZv55ikoYygA5boA3U2lR/LoSHKPYB5NIWPLwCfGAAroOHneCWUagNj/4D4f3l5jTQpL97IPNL6rAWZGV5IN7yWuU0WekW9u7wsa6apm5CMkgtMM2iG8W16DrMmzotbfQcxi5SSd5iEUrW0Ged6oqRTn94Ilm0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 407Js77i028152; Mon, 8 Jan 2024 02:36:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : to : cc : from : subject : content-type : content-transfer-encoding; s=pp1; bh=OJZEzEERBu+ygFcS841LAW/fuBepcAdSLhPfmamA2e0=; b=LIWMjn2V+kq2Ji0oN1jYxoZ7GO2RsHmwgYgeXoMVaIf/EvEXGnJeRmQWxA4f3q6noxjd 4d8fpxTMaH6FsOf5ett5OlvUpe7nT1S4BsO3nKG/IQ9AEkd3vpWcHfI/EDnQL/njd56U pvFitaPk3gp1MDGh43F1U4Sg0t80Dnif6u6T9DrMgNzuRwUfkQWihmSvfHPG9qTJTfnD gFO1bjO+/6QwWBmpbSMiBIpq+yJgFFOqfq8hoyBTCqL3WmP2stL+aIKiPfg9Hb2x6+mB dZai8V0qjnkqYkx23K2W9XH+YaiPdJfnDVX531jMTsBeGYFhdTqP6REYMbdW40WQj2nk Eg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vf1uy9hah-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 02:36:05 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4082UgTh013435; Mon, 8 Jan 2024 02:36:05 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 3vf1uy9h99-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 02:36:04 +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 40811rPD022781; Mon, 8 Jan 2024 02:35:57 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vfhjy5nce-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 02:35:57 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4082Ztxg18940452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 8 Jan 2024 02:35:55 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1C7D20043; Mon, 8 Jan 2024 02:35:55 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF5CF20040; Mon, 8 Jan 2024 02:35:53 +0000 (GMT) Received: from [9.197.233.114] (unknown [9.197.233.114]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 8 Jan 2024 02:35:53 +0000 (GMT) Message-ID: Date: Mon, 8 Jan 2024 10:35:52 +0800 MIME-Version: 1.0 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 To: GCC Patches Cc: Segher Boessenkool , Peter Bergner , David Edelsohn , Jakub Jelinek From: "Kewen.Lin" Subject: [PATCH] rs6000: Make copysign (x, -1) back to -abs (x) for IEEE128 float [PR112606] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 2ba0MNvRcSQ1ikSDZqZAQj9oQYycLk6k X-Proofpoint-GUID: NleKLRTci-QrQmIXUokejXM9t6c-PKpa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-07_15,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=940 malwarescore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401080017 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, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787488050317115280 X-GMAIL-MSGID: 1787488050317115280 Hi, I noticed that commit r14-6192 can't help PR112606 #c3 as it only takes care of SF/DF but TF/KF can still suffer the issue. Similar to commit r14-6192, this patch is to take care of copysign3 with IEEE128 as well. Bootstrapped and regtested on powerpc64-linux-gnu P8/P9 and powerpc64le-linux-gnu P9 and P10. I'm going to push this soon. BR, Kewen ----- PR target/112606 gcc/ChangeLog: * config/rs6000/rs6000.md (copysign3 IEEE128): Change predicate of the last argument from altivec_register_operand to any_operand. If operands[2] is CONST_DOUBLE, emit abs or neg abs depending on its sign otherwise if it doesn't satisfy altivec_register_operand, force it to REG using copy_to_mode_reg. --- gcc/config/rs6000/rs6000.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) -- 2.42.0 diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index c880cec33a2..bc8bc6ab060 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -15020,9 +15020,27 @@ (define_insn "sqrt2" (define_expand "copysign3" [(use (match_operand:IEEE128 0 "altivec_register_operand")) (use (match_operand:IEEE128 1 "altivec_register_operand")) - (use (match_operand:IEEE128 2 "altivec_register_operand"))] + (use (match_operand:IEEE128 2 "any_operand"))] "FLOAT128_IEEE_P (mode)" { + /* Middle-end canonicalizes -fabs (x) to copysign (x, -1), + but PowerPC prefers -fabs (x). */ + if (CONST_DOUBLE_AS_FLOAT_P (operands[2])) + { + if (real_isneg (CONST_DOUBLE_REAL_VALUE (operands[2]))) + { + rtx abs_res = gen_reg_rtx (mode); + emit_insn (gen_abs2 (abs_res, operands[1])); + emit_insn (gen_neg2 (operands[0], abs_res)); + } + else + emit_insn (gen_abs2 (operands[0], operands[1])); + DONE; + } + + if (!altivec_register_operand (operands[2], mode)) + operands[2] = copy_to_mode_reg (mode, operands[2]); + if (TARGET_FLOAT128_HW) emit_insn (gen_copysign3_hard (operands[0], operands[1], operands[2]));