From patchwork Fri Jan 12 06:48:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 187584 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp507dyc; Thu, 11 Jan 2024 22:49:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEh7V5PEDo5/+mKVrbNROyykTyumsy7Z1ry6Rv0rf7DWZica1Bxz9bIWHrSeWhSFCa5vbG X-Received: by 2002:a05:622a:204:b0:429:bd89:d8e2 with SMTP id b4-20020a05622a020400b00429bd89d8e2mr1024024qtx.88.1705042170408; Thu, 11 Jan 2024 22:49:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705042170; cv=pass; d=google.com; s=arc-20160816; b=tXlmAwd5Iynzsn62LqGkpaIG9kHLeAiSIajkl72tYzUUFE13kfFl7oqx3hHTTcVeQi 6N/Nwusz/g1c0P6btp4gf88FLdrO+xmDRvsUYrSk/JkE3qT/d0tQGhhD/KYycCzeNNbH nXs/R7ilCCnTX/yi/0d1g8SUZnbzXeB5WJO4jM8y1hm1ofA3B8XpxAGg30B/ob8LXbhf bzjTKTEPrbJtAzH0L1upFCr4CfT//BxC/nrGgbbLr+oQHxCzcmsI3O7lf9FGx5wryOPL NUlNc7v3BdAHixLJcMsdej6yjiBxvD3mCMYEAYdaxDIpRFBJ1/GToC5w953ytBLfkhxJ Ootw== 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=8bG/Jog3jP5/NbKW4pzAwI4Jo+a3TpAqwRp8JA7A6C0=; fh=3eUSxJU+9IWNwGHlMjnmqDQDnJfeMKAjlglEUO7a4vw=; b=PcXlf5xarR6J6TrY//+Lgg5UtrcP//sLQsay71ePWwkdbNt1l2DRKxCvBiepieSEDg wBK30mPW9v76XQJ6VM+kOMQ6DhU526bBDvuljwN9QFMXXNEEuRpSmV8gXD75AUFG+UY4 TJl+Tw/1orJpj+H5ZOetXJGnipaCAJ+Wh+KgjayUWEipOloAk2adNEvAOX51cW+SB/ha cEIgPo9KyMkUWXjCOH4gDjgeyqXPc0YA4+YwgaC+X2zMFw/EwsqBgh4diwJhNXWDyrsD CLrmUCJcjoMxoSDw5Iwpe+SWVJg5UsTiJS2gZdBYW4DXUisnMlyxgyLXVMMH/sBUkYYV C8fA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=OwKHDq9s; arc=pass (i=1); 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o12-20020ac87c4c000000b00429a9eff4d8si2533681qtv.517.2024.01.11.22.49.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 22:49:30 -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=@ibm.com header.s=pp1 header.b=OwKHDq9s; arc=pass (i=1); 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 035753858C29 for ; Fri, 12 Jan 2024 06:49:30 +0000 (GMT) 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 B39073858D1E for ; Fri, 12 Jan 2024 06:48:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B39073858D1E 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 B39073858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705042134; cv=none; b=i0jUQXE9rJaNuSe52yqF/2LTGHrnooGrd9J19iVoegwp1nyQyW1IPJ3am4EI7gJIH8tcodvwZ1VFsd4ESmjbP5xN9yIQFLAuTXhauAiBfee8+VjzaBOLWkzl765ULrXvtyehic0BNdDFNPcYH5Qnzo270Wb/Hji0mmFe2zNC9K8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705042134; c=relaxed/simple; bh=Jd8rL5bobie54qvv6BKTuRWsz7zLieqWB7QO2eb9V1k=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=IN3ff4uGdKALOpXl/DM8Dmcx8ibp5Ptnbb2BL2JE7sPTXXC6Y5QgWEfke/nu18ArClW/V8+X0vTzCKk1aFXqAJ7UC9dHzo+NelTv80Nj3COEVNx7TaO9eYzVo6kBcU2adiAX6+cdDrlLh1KS4Mesx+jWeKETgh4yM1VRRNdaIpo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40C4KpDc005503; Fri, 12 Jan 2024 06:48:52 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=8bG/Jog3jP5/NbKW4pzAwI4Jo+a3TpAqwRp8JA7A6C0=; b=OwKHDq9suTQwBS7SKkdgmzO+VB71wBZb7VbKYs43oUmVKaUy2we9yEKxUwI9ar5fYQbr KwtPgBdsEHbhC3Q9NmzfvcinweQWhXysj5BOMHO6C5oVdgh8+LZsVtjLa65s0nqBWhqX bli0t8RzflJv/jfB4gCaOO3I31TGiEskmhSym1xdazcpqu6Yq/YMpG0y1RYXwBehSUkF ha9Y82CuRcDuuvp6V0BlBIM1K05p+IPgGqDeE1+ad9LsJjp6uZWYynrnKGqY2DyIIRPi mF9L9vte/h6FFOdVHwfRo+vJ4RV26lmCRs4O5t18tWVa+txBQ07tVBLfjX2hVCAAIEFw mg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vjj70m608-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Jan 2024 06:48:51 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40C6jw8i026381; Fri, 12 Jan 2024 06:48:51 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vjj70m600-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Jan 2024 06:48:51 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40C3Udpt022882; Fri, 12 Jan 2024 06:48:50 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vfj6p0egf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Jan 2024 06:48:50 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40C6ml7O197328 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jan 2024 06:48:47 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 76CC72005A; Fri, 12 Jan 2024 06:48:47 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAB3620040; Fri, 12 Jan 2024 06:48:45 +0000 (GMT) Received: from [9.197.244.15] (unknown [9.197.244.15]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Jan 2024 06:48:45 +0000 (GMT) Message-ID: <166fd582-e55f-4d5f-8be0-67f5ec67fc49@linux.ibm.com> Date: Fri, 12 Jan 2024 14:48:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner From: HAO CHEN GUI Subject: [PATCH, rs6000] Enable block compare expand on P9 with m32 and mpowerpc64 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: oI0mvRqNcVbjJh7tXsxcRUMBRXqAviii X-Proofpoint-ORIG-GUID: mZ_uh3Kka39u0_jacypXAj0VI9ZYM91F 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-12_02,2024-01-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 phishscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 suspectscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401120051 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, 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: 1787866299181176205 X-GMAIL-MSGID: 1787866299181176205 Hi, On P9 "setb" is used to set the result of block compare. So it works with m32 and mpowerpc64. On P8, carry bit is used. So it can't work with m32 and mpowerpc64. This patch enables block compare expand for m32 and mpowerpc64 on P9. Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no regressions. Is this OK for trunk? Thanks Gui Haochen ChangeLog rs6000: Enable block compare expand on P9 with m32 and mpowerpc64 gcc/ * config/rs6000/rs6000-string.cc (expand_block_compare): Enable P9 with m32 and mpowerpc64. gcc/testsuite/ * gcc.target/powerpc/block-cmp-1.c: Exclude m32 and mpowerpc64. * gcc.target/powerpc/block-cmp-4.c: Likewise. * gcc.target/powerpc/block-cmp-8.c: New. patch.diff diff --git a/gcc/config/rs6000/rs6000-string.cc b/gcc/config/rs6000/rs6000-string.cc index 018b87f2501..346708071b5 100644 --- a/gcc/config/rs6000/rs6000-string.cc +++ b/gcc/config/rs6000/rs6000-string.cc @@ -1677,11 +1677,12 @@ expand_block_compare (rtx operands[]) /* TARGET_POPCNTD is already guarded at expand cmpmemsi. */ gcc_assert (TARGET_POPCNTD); - /* This case is complicated to handle because the subtract - with carry instructions do not generate the 64-bit - carry and so we must emit code to calculate it ourselves. - We choose not to implement this yet. */ - if (TARGET_32BIT && TARGET_POWERPC64) + /* For P8, this case is complicated to handle because the subtract + with carry instructions do not generate the 64-bit carry and so + we must emit code to calculate it ourselves. We skip it on P8 + but setb works well on P9. */ + if (TARGET_32BIT && TARGET_POWERPC64 + && !TARGET_P9_MISC) return false; /* Allow this param to shut off all expansion. */ diff --git a/gcc/testsuite/gcc.target/powerpc/block-cmp-1.c b/gcc/testsuite/gcc.target/powerpc/block-cmp-1.c index bcf0cb2ab4f..cd076cf1dce 100644 --- a/gcc/testsuite/gcc.target/powerpc/block-cmp-1.c +++ b/gcc/testsuite/gcc.target/powerpc/block-cmp-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -mdejagnu-cpu=power8 -mno-vsx" } */ +/* { dg-skip-if "" { has_arch_ppc64 && ilp32 } } */ /* { dg-final { scan-assembler-not {\mb[l]? memcmp\M} } } */ /* Test that it still can do expand for memcmpsi instead of calling library diff --git a/gcc/testsuite/gcc.target/powerpc/block-cmp-4.c b/gcc/testsuite/gcc.target/powerpc/block-cmp-4.c index c86febae68a..9373b53a3a4 100644 --- a/gcc/testsuite/gcc.target/powerpc/block-cmp-4.c +++ b/gcc/testsuite/gcc.target/powerpc/block-cmp-4.c @@ -1,5 +1,6 @@ /* { dg-do compile { target be } } */ /* { dg-options "-O2 -mdejagnu-cpu=power7" } */ +/* { dg-skip-if "" { has_arch_ppc64 && ilp32 } } */ /* { dg-final { scan-assembler-not {\mb[l]? memcmp\M} } } */ /* Test that it does expand for memcmpsi instead of calling library on diff --git a/gcc/testsuite/gcc.target/powerpc/block-cmp-8.c b/gcc/testsuite/gcc.target/powerpc/block-cmp-8.c new file mode 100644 index 00000000000..b470f873973 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/block-cmp-8.c @@ -0,0 +1,8 @@ +/* { dg-do run { target ilp32 } } */ +/* { dg-options "-O2 -m32 -mpowerpc64" } */ +/* { dg-require-effective-target has_arch_ppc64 } */ +/* { dg-timeout-factor 2 } */ + +/* Verify memcmp on m32 mpowerpc64 */ + +#include "../../gcc.dg/memcmp-1.c"