From patchwork Thu Nov 9 01:32:07 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: 163197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp157081vqs; Wed, 8 Nov 2023 17:33:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGht6YOOo0wcM7ffec0q9EoqT039NtlrzqKV0UClEYsizD4Y7VxbzVVqGR8HpsmEPU3mGuh X-Received: by 2002:ac8:5856:0:b0:41c:e460:83ef with SMTP id h22-20020ac85856000000b0041ce46083efmr4236318qth.65.1699493581895; Wed, 08 Nov 2023 17:33:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699493581; cv=pass; d=google.com; s=arc-20160816; b=UqCJ08YPMJzKdlx8damQs1VgpoO1YZ9Cb/F2nnlDEuDsMTXGl74j/fd1FglAEXeG7b bJ1VhpTviVX+RbCR7X1go8ya8//6JRMSEDW+ACTTSxhqEnBLw74n3sjz8wekwIGeAHiT RJH6/Fxt9XyXmLt8wJOA564eqbJNLTE2Q8DgdysAukgg8+T5JdatMAmL1Mhja+Da5Y+2 glcN5kgw2ubRPWVDRSYroH3gq8WSlVQrW28NQKheXIuPmS7XNSzQc0v48/mj7ISZuEPO /6eppzYdQtvtSleFSV9YN3mPciz77U6THWtcJL2fBCKH8I1BrMHO0fK2nIziLIy/mFdl +pQA== 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=JOn0EiNWcl/geZqmZfd+woUNVJsNIaSNSjaUuyIO7JE=; fh=3eUSxJU+9IWNwGHlMjnmqDQDnJfeMKAjlglEUO7a4vw=; b=Tp7zql0GkxD4bJ0knZvns0f4eWpWg6Du+5E1+e2hHC1dS5kVXdRK6gkjmSyEcDd3nj mt36/4cUA8LbyNxwEGWOxhPKl8pZQ/g9ey2t/I/dPWclV7KShiRWaQMfC7H62xXGX6Sw AJ8U+LA46TqJls5NhLpJj69qQaMLeLmIx5ms+M4jr9ggExvd8dtUqHviHavx9E4RKFRj MC9oJFsfPiR2/rcI9MWau+4zst8dflMi1P+KPXiUVqR8V6jm9ux3SKIB3b67GjCAOUNi IQBE63s+Vlmjxo7TPC+cRfvuCs0dqDd9qUpe3iFb1ccE8pNyD+56t/IPYzn3R5OpSxCw huoA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="CztiaFP/"; 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 f21-20020a05622a105500b00418113fb90asi2202653qte.425.2023.11.08.17.33.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 17:33:01 -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="CztiaFP/"; 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 DFC8838618F0 for ; Thu, 9 Nov 2023 01:32:57 +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 7FF4E38618AC for ; Thu, 9 Nov 2023 01:32:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FF4E38618AC 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 7FF4E38618AC 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=1699493536; cv=none; b=KuJtzfSTmlZuRyQ16yg4Le6EDKsHQYTZmbVbj+EUbGSPP1dOmOr/FaYKMnZ2Ij9IuVQNtzPkADCon0XhjhXfWTSc7vo+3NjsuFExlmceQFgP6stxFWgPWCruqN3wdIc7gBv0sHK8Nja6s33j6vVUyxeXGwzTa7+f3OELS9nwc9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699493536; c=relaxed/simple; bh=gYmZR08dwM/W5U/UORnkMp4yscSUtWEJn4N+rdIh5sY=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=bTIeUhngoA2so/o7eOwgvOFL5LDqJyQSpHslm+xY0r73s6BfVmfsxaefoOatJ8RnTX4TIfnCLGZ73U8tAXn1P9gdiUDEgd8pyES46w8bv3sVsYfLcNBnjptoghAECx3tpNBwaLQt7apxMzWN7lTcHGYuk41m0BG+lD6/vtYoqjY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A91HUtH006726; Thu, 9 Nov 2023 01:32:15 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=JOn0EiNWcl/geZqmZfd+woUNVJsNIaSNSjaUuyIO7JE=; b=CztiaFP/l1l5HjbYBM+3wTNMVTfZVBiTlFNMTQfsmYbZ8B1h7vQLHSYXTwlXVe3U17YU HXpoK5OgttoUvRy0iGXG0ICDO4iwPgMNm6Q+WHfkcnk4/EfsFCLryegbo4xr92t5nxF4 kRfCYGQBrPk45H/cYr8L93OcrhoGhzrl9T3NN6MzwQImHgUg/gRz9+NUkOfgKd+Hj8r0 /JQLTsgkkB4t9crIzjDKTLNIwzrqnqRGHu6KR67YQ3k9rk/iKHr/obPeXQte4nhkkXpa Gkp9L6C8Z+Jg04u4wyIBTvaeCbHX2bikrJIH8swlxdpLWx2SpmW3yRAgP4pm3zDQ0CHj sQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u8nmp0ady-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Nov 2023 01:32:14 +0000 Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3A91HZAs007130; Thu, 9 Nov 2023 01:32:14 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u8nmp0adr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Nov 2023 01:32:14 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3A9172Ij014309; Thu, 9 Nov 2023 01:32:13 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w220rgp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Nov 2023 01:32:13 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3A91WALU10420836 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 9 Nov 2023 01:32:10 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 77B4820049; Thu, 9 Nov 2023 01:32:10 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D0D320040; Thu, 9 Nov 2023 01:32:08 +0000 (GMT) Received: from [9.200.103.64] (unknown [9.200.103.64]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 9 Nov 2023 01:32:08 +0000 (GMT) Message-ID: <4aad8e36-0947-4bf8-9e3c-1c105c89e9a2@linux.ibm.com> Date: Thu, 9 Nov 2023 09:32:07 +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-3v3, rs6000] Fix regression cases caused 16-byte by pieces move [PR111449] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: OjPZlnJare2nmlrs8aFK3k8K3brDat_4 X-Proofpoint-ORIG-GUID: ZJgji9MK4q4H6aCXD06YV4Ls9hgEUS4b X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-09_01,2023-11-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311090009 X-Spam-Status: No, score=-12.3 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, 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: 1782048182148820282 X-GMAIL-MSGID: 1782048182148820282 Hi, Originally 16-byte memory to memory is expanded via pattern. expand_block_move does an optimization on P8 LE to leverage V2DI reversed load/store for memory to memory move. Now it's done by 16-byte by pieces move and the optimization is lost. This patch adds an insn_and_split pattern to retake the optimization. Compared to the previous version, the main change is to move fix for two regression cases to former patch and change the condition of pattern. Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no regressions. Is this OK for trunk? Thanks Gui Haochen ChangeLog rs6000: Fix regression cases caused 16-byte by pieces move The previous patch enables 16-byte by pieces move. Originally 16-byte move is implemented via pattern. expand_block_move does an optimization on P8 LE to leverage V2DI reversed load/store for memory to memory move. Now 16-byte move is implemented via by pieces move and finally split to two DImode load/store. This patch creates an insn_and_split pattern to retake the optimization. gcc/ PR target/111449 * config/rs6000/vsx.md (*vsx_le_mem_to_mem_mov_ti): New. gcc/testsuite/ PR target/111449 * gcc.target/powerpc/pr111449-2.c: New. patch.diff diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index f3b40229094..3f71e96dc6b 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -414,6 +414,29 @@ (define_mode_attr VM3_char [(V2DI "d") ;; VSX moves +;; TImode memory to memory move optimization on LE with p8vector +(define_insn_and_split "*vsx_le_mem_to_mem_mov_ti" + [(set (match_operand:TI 0 "indexed_or_indirect_operand" "=Z") + (match_operand:TI 1 "indexed_or_indirect_operand" "Z"))] + "!BYTES_BIG_ENDIAN + && TARGET_VSX + && !TARGET_P9_VECTOR + && !MEM_VOLATILE_P (operands[0]) + && !MEM_VOLATILE_P (operands[1]) + && can_create_pseudo_p ()" + "#" + "&& 1" + [(const_int 0)] +{ + rtx tmp = gen_reg_rtx (V2DImode); + rtx src = adjust_address (operands[1], V2DImode, 0); + emit_insn (gen_vsx_ld_elemrev_v2di (tmp, src)); + rtx dest = adjust_address (operands[0], V2DImode, 0); + emit_insn (gen_vsx_st_elemrev_v2di (dest, tmp)); + DONE; +} + [(set_attr "length" "16")]) + ;; The patterns for LE permuted loads and stores come before the general ;; VSX moves so they match first. (define_insn_and_split "*vsx_le_perm_load_" diff --git a/gcc/testsuite/gcc.target/powerpc/pr111449-2.c b/gcc/testsuite/gcc.target/powerpc/pr111449-2.c new file mode 100644 index 00000000000..7003bdc0208 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr111449-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target { has_arch_pwr8 } } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-options "-mvsx -O2" } */ + +/* Ensure 16-byte by pieces move is enabled. */ + +void move1 (void *s1, void *s2) +{ + __builtin_memcpy (s1, s2, 16); +} + +void move2 (void *s1) +{ + __builtin_memcpy (s1, "0123456789012345", 16); +} + +/* { dg-final { scan-assembler-times {\mlxvd2x\M|\mp?lxv\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mstxvd2x\M|\mstxv\M} 2 } } */