From patchwork Mon Sep 4 05:33:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 137439 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp903552vqo; Sun, 3 Sep 2023 22:34:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNEHWgBMeUYvIUgze5+b2XEV1jmUUOHr2+m8dMyJ9qpIZVmOknuc4LgP75SkfPSjWx1Jy+ X-Received: by 2002:a17:906:8a55:b0:9a5:ebe4:de6c with SMTP id gx21-20020a1709068a5500b009a5ebe4de6cmr5765364ejc.55.1693805683078; Sun, 03 Sep 2023 22:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693805683; cv=none; d=google.com; s=arc-20160816; b=T5v17t/w3HWR6DxzFlfbup+VtdFV3n/rCKvQo61Ji2Yqb5WqihB+TinoZJOM+e019L SOLdzvqOgLG6e5AlkeE+gUClmweCQBTwf/42lnj7a/CXyXJi3XgygJIVfqKFBuBL161R mJi5LSbvc1ITzE6V8d4yb8+32a4foGvNbNIAZU4fKwjinbWzvRjhRrUUleuZNP4XkDXs byiScO+q2LjfcBHV0JkI9zOBHQVwqxi2Hcn5i5JZT5TbNfTvgl+gIq5crjnGONnlI5eI UOva05vmlHTNpgPBzsYW62guEEeMe5tUkXodAV+PGXm1YslClTsbCzDDplCql8LyTYeq W4+A== 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 :mime-version:content-transfer-encoding:subject:to:content-language :user-agent:date:message-id:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=SAG1zDpNPM8tuH8zlklSl0y3c6NeRJU5lluakDCREis=; fh=N5xeAcoHiHemsNOe+rgC7MoBrkuY8gvPzSL77/KkM4I=; b=VGM4zoIWRGBNLD8P2OREqKVwT+ublpzUywBDI4PhZeCaEU7e3h1Q+lUj+SynhCwVJf encvwJ1xwFu4vQ8fbkpAD6F/hgaC7UvYe/sUX5PQXwWV7NSj+B4o0O6kAxzWBizBEQNb GhY0kktCcGQOYLgkO0RtySiDd3OBxeYUPtlAcib7xZeiDvI5YCxbJYwkU+AJH1Y1f+fw KFX+Fs9i3vzq38U2QuqDF39yfIKxR77pvC00R9nYv1y/gmo/ZVa9YiEtp/szXeu1ySCF BcK8UHcoCo6kAoT4nZePxe58UA3FAFM+Lm1UHmnZz/nyqAUgwPR+LZXaDDD6zZV+lkC3 dd+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HrUWHIsV; 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 w7-20020a056402128700b0052a1d5122dasi5728956edv.331.2023.09.03.22.34.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Sep 2023 22:34:43 -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=HrUWHIsV; 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 E7BCC3858425 for ; Mon, 4 Sep 2023 05:34:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7BCC3858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693805681; bh=SAG1zDpNPM8tuH8zlklSl0y3c6NeRJU5lluakDCREis=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=HrUWHIsV5m9KIVPaIcTq7ztoy/3uOjKGDjllaBURh5C0AvjMFF4UbLojxpk49Hfvl ghQcab+yYu0rH3xvXnvi980wngcRCHrZ5D7GdmAr4pXzaUukTkyvRJs15abiqn/XA1 BzZz+DBmJCBYhOVnAYNoSLADVwAExSfSX2wC96gY= 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 CB2B93858D33 for ; Mon, 4 Sep 2023 05:33:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB2B93858D33 Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38458u6F002813; Mon, 4 Sep 2023 05:33:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sw83ah36v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Sep 2023 05:33:55 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3845PPjF030174; Mon, 4 Sep 2023 05:33:55 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sw83ah36a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Sep 2023 05:33:55 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3843x8SJ011121; Mon, 4 Sep 2023 05:33:54 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3svj317f86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Sep 2023 05:33:54 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3845XmBD14025470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Sep 2023 05:33:49 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DEEC02007C; Mon, 4 Sep 2023 05:33:48 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D7B122005A; Mon, 4 Sep 2023 05:33:46 +0000 (GMT) Received: from [9.200.56.60] (unknown [9.200.56.60]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 Sep 2023 05:33:45 +0000 (GMT) Message-ID: <45dac533-e364-d6ba-a34c-3248a99cfa96@linux.ibm.com> Date: Mon, 4 Sep 2023 13:33:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: en-US To: gcc-patches Subject: [PATCH-2v2, rs6000] Implement 32bit inline lrint [PR88558] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 36a__47rgLmmoi9_uiVNwR2hBFNvT7wX X-Proofpoint-ORIG-GUID: _1E_wGe0nZSE0OYNmK3PWNyQb9io-AmX X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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-09-04_03,2023-08-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 spamscore=0 impostorscore=0 adultscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=740 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309040044 X-Spam-Status: No, score=-12.7 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_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: , X-Patchwork-Original-From: HAO CHEN GUI via Gcc-patches From: HAO CHEN GUI Reply-To: HAO CHEN GUI Cc: Peter Bergner , David , Segher Boessenkool Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776083987771490588 X-GMAIL-MSGID: 1776083987771490588 Hi, This patch implements 32bit inline lrint by "fctiw". It depends on the patch1 to do SImode move from FP registers on P7. Compared to last version, the main change is to add tests for "lrintf" and adjust the count of corresponding instructions. https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628436.html Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Thanks Gui Haochen ChangeLog rs6000: support 32bit inline lrint gcc/ PR target/88558 * config/rs6000/rs6000.md (lrintdi2): Remove TARGET_FPRND from insn condition. (lrintsi2): New insn pattern for 32bit lrint. gcc/testsuite/ PR target/106769 * gcc.target/powerpc/pr88558.h: New. * gcc.target/powerpc/pr88558-p7.c: New. * gcc.target/powerpc/pr88558-p8.c: New. patch.diff diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index edf49bd74e3..a41898e0e08 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -6655,10 +6655,18 @@ (define_insn "lrintdi2" [(set (match_operand:DI 0 "gpc_reg_operand" "=d") (unspec:DI [(match_operand:SFDF 1 "gpc_reg_operand" "")] UNSPEC_FCTID))] - "TARGET_HARD_FLOAT && TARGET_FPRND" + "TARGET_HARD_FLOAT" "fctid %0,%1" [(set_attr "type" "fp")]) +(define_insn "lrintsi2" + [(set (match_operand:SI 0 "gpc_reg_operand" "=d") + (unspec:SI [(match_operand:SFDF 1 "gpc_reg_operand" "")] + UNSPEC_FCTIW))] + "TARGET_HARD_FLOAT && TARGET_POPCNTD" + "fctiw %0,%1" + [(set_attr "type" "fp")]) + (define_insn "btrunc2" [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d,wa") (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "d,wa")] diff --git a/gcc/testsuite/gcc.target/powerpc/pr88558-p7.c b/gcc/testsuite/gcc.target/powerpc/pr88558-p7.c new file mode 100644 index 00000000000..f302491c4d0 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr88558-p7.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-math-errno -mdejagnu-cpu=power7" } */ + +/* -fno-math-errno is required to make {i,l,ll}rint inlined */ + +#include "pr88558.h" + +/* { dg-final { scan-assembler-times {\mfctid\M} 3 { target lp64 } } } */ +/* { dg-final { scan-assembler-times {\mfctid\M} 1 { target ilp32 } } } */ +/* { dg-final { scan-assembler-times {\mfctiw\M} 1 { target lp64 } } } */ +/* { dg-final { scan-assembler-times {\mfctiw\M} 3 { target ilp32 } } } */ +/* { dg-final { scan-assembler-times {\mstfiwx\M} 1 { target lp64 } } } */ +/* { dg-final { scan-assembler-times {\mstfiwx\M} 3 { target ilp32 } } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr88558-p8.c b/gcc/testsuite/gcc.target/powerpc/pr88558-p8.c new file mode 100644 index 00000000000..33398aa74c2 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr88558-p8.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-options "-O2 -fno-math-errno -mdejagnu-cpu=power8" } */ + +/* -fno-math-errno is required to make {i,l,ll}rint inlined */ + +#include "pr88558.h" + +/* { dg-final { scan-assembler-times {\mfctid\M} 3 { target lp64 } } } */ +/* { dg-final { scan-assembler-times {\mfctid\M} 1 { target ilp32 } } } */ +/* { dg-final { scan-assembler-times {\mfctiw\M} 1 { target lp64 } } } */ +/* { dg-final { scan-assembler-times {\mfctiw\M} 3 { target ilp32 } } } */ +/* { dg-final { scan-assembler-times {\mmfvsrwz\M} 1 { target lp64 } } } */ +/* { dg-final { scan-assembler-times {\mmfvsrwz\M} 3 { target ilp32 } } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr88558.h b/gcc/testsuite/gcc.target/powerpc/pr88558.h new file mode 100644 index 00000000000..698640c0ef7 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr88558.h @@ -0,0 +1,19 @@ +long int test1 (double a) +{ + return __builtin_lrint (a); +} + +long long test2 (double a) +{ + return __builtin_llrint (a); +} + +int test3 (double a) +{ + return __builtin_irint (a); +} + +long int test4 (float a) +{ + return __builtin_lrintf (a); +}