From patchwork Mon Feb 20 02:04:27 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: 59323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1218861wrn; Mon, 20 Feb 2023 01:52:10 -0800 (PST) X-Google-Smtp-Source: AK7set9+F6VuU7raTcdn81U3Fg0tFxOfVOuawo0qQpueCCJPOJwrEpfGlVGdo+P3fffuRoSL48LW X-Received: by 2002:aa7:d688:0:b0:4a2:4a89:2331 with SMTP id d8-20020aa7d688000000b004a24a892331mr1387045edr.29.1676886730731; Mon, 20 Feb 2023 01:52:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676886730; cv=none; d=google.com; s=arc-20160816; b=unv7eJliDrjSPlwunq+fjSkm0G7N34kLrPIP2/Ai5zQWRiGNzt0+0v8Sx0mnX+IfC8 kjeMcfKuIOOj2mu3cOrCBLp9pNATVUZdJHhAELhi9pu/Vl2SZdDpoimNKQKOTwKoQmgH cYhvRYibS/JpF9RoeQwergBh98S2aZCC+VobsmwuFrsu3r3EydKTI40kOV65+qIGbWqe SzJMzW0Kk9IPUunGJnRMVydp0MbWFfiVtn/ohhLijy3AHvI6HiXknNT9gjIcVcLDmgI3 BZLKvJWgthHwPbXex30gqp0U2TgnLGzay92UPQbopGGgPXJaQX2+o2fPzjYa4dhwkGs6 rpMA== 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 :content-transfer-encoding:cc:subject:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=C6ckSG2A3CyTNeWBl4iuk9htUkr2vB3KqyglQG8243I=; b=FD/QxJ0dTJMbbut97Ef/lVsRE1VFjQr/fNCZJHPWakPmR68v+SvhilGHYF/gxG57VI 0f6rjXMzHdhm+IsxoA0M/4JaZd4v2c9ED1QhlPeXG6igvRVvrGkC87Srtd53gPpEsUB6 r+DWoguNQCQAIpM95BaoMazunpg+UcHs2+pEuzV74XEwqTHKBurwuBq2uGGhcOuS1yfi 5ldlcBN2jN9CoZqPzzYzJcg9QtrJjMCDy/ew6tr6MArwWkPJlKABPBKprkLX6kGq3L1b RiPyC+QsFdIfniCuc1xDIJC7RfW2PVbEEEgSIMZYRANp/8uxw2crBp6iUHjz5/Zni47M 8XVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=LqGgrIEQ; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bf24-20020a0564021a5800b004ad041aa896si14685601edb.185.2023.02.20.01.52.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 01:52:10 -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=@gcc.gnu.org header.s=default header.b=LqGgrIEQ; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 200C23896C02 for ; Mon, 20 Feb 2023 09:50:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 200C23896C02 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676886616; bh=C6ckSG2A3CyTNeWBl4iuk9htUkr2vB3KqyglQG8243I=; h=Date:To:Subject:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=LqGgrIEQHyoHYolr7xDMoaVXwSCvoUaS8N4l+fG7P1ZQjXauHdQ4GIgcU9q1ahq2V NZgniWnJEaT9wIf3bykbwiJE4jahkNUq2hVddDKlKC68kbqIMBRAMPZV36eQwiEz/s 1p5VLQ5lMRPADNta1fOHFkP7jvHMvaanFGVQ/CXo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 26CEF38493E6 for ; Mon, 20 Feb 2023 09:49:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 26CEF38493E6 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pTvXl-0005Ao-SA for gcc-patches@gcc.gnu.org; Sun, 19 Feb 2023 21:04:43 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31JMe2ll026049; Mon, 20 Feb 2023 02:04:36 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nuse5x059-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:04:36 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31K1dxk9010504; Mon, 20 Feb 2023 02:04:35 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nuse5x04j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:04:35 +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 31JJo9CC003913; Mon, 20 Feb 2023 02:04:34 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3ntpa6a1j7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:04:33 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31K24UBm22413610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Feb 2023 02:04:30 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64C4B20043; Mon, 20 Feb 2023 02:04:30 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 946B520040; Mon, 20 Feb 2023 02:04:28 +0000 (GMT) Received: from [9.197.250.3] (unknown [9.197.250.3]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 20 Feb 2023 02:04:28 +0000 (GMT) Message-ID: <4005d148-ca54-880b-6c97-7f2fae15d8d1@linux.ibm.com> Date: Mon, 20 Feb 2023 10:04:27 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Content-Language: en-US To: gcc-patches Subject: [PATCH, rs6000] Merge two vector shift when their sources are the same Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 4yGJ-u6OXTVicqAU8g5aYVKbqn9U-X3i X-Proofpoint-GUID: 00NjvMvH5f9hLpEz9DXA-nJOH-YsduPJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-19_15,2023-02-17_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302200017 Received-SPF: pass client-ip=148.163.158.5; envelope-from=guihaoc@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=unavailable 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: HAO CHEN GUI via Gcc-patches From: HAO CHEN GUI Reply-To: HAO CHEN GUI 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?1758343180091886875?= X-GMAIL-MSGID: =?utf-8?q?1758343180091886875?= Hi, This patch merges two "vsldoi" insns when their sources are the same. Particularly, it is simplified to be one move if the total shift is multiples of 16 bytes. Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Thanks Gui Haochen ChangeLog 2023-02-20 Haochen Gui gcc/ * config/rs6000/altivec.md (*altivec_vsldoi_dup_): New insn_and_split to merge two vsldoi. gcc/testsuite/ * gcc.target/powerpc/vsldoi_merge.c: New. patch.diff diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index 84660073f32..22e9c4c1fc5 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -2529,6 +2529,35 @@ (define_insn "altivec_vsldoi_" "vsldoi %0,%1,%2,%3" [(set_attr "type" "vecperm")]) +(define_insn_and_split "*altivec_vsldoi_dup_" + [(set (match_operand:VM 0 "register_operand" "=v") + (unspec:VM [(unspec:VM [(match_operand:VM 1 "register_operand" "v") + (match_operand:VM 2 "register_operand" "v") + (match_operand:QI 3 "immediate_operand" "i")] + UNSPEC_VSLDOI) + (unspec:VM [(match_dup 1) + (match_dup 2) + (match_dup 3)] + UNSPEC_VSLDOI) + (match_operand:QI 4 "immediate_operand" "i")] + UNSPEC_VSLDOI))] + "TARGET_ALTIVEC" + "#" + "&& 1" + [(const_int 0)] +{ + unsigned int shift1 = UINTVAL (operands[3]); + unsigned int shift2 = UINTVAL (operands[4]); + + unsigned int shift = (shift1 + shift2) % 16; + if (shift) + emit_insn (gen_altivec_vsldoi_ (operands[0], operands[1], + operands[1], GEN_INT (shift))); + else + emit_move_insn (operands[0], operands[1]); + DONE; +}) + (define_insn "altivec_vupkhs" [(set (match_operand:VP 0 "register_operand" "=v") (unspec:VP [(match_operand: 1 "register_operand" "v")] diff --git a/gcc/testsuite/gcc.target/powerpc/vsldoi_merge.c b/gcc/testsuite/gcc.target/powerpc/vsldoi_merge.c new file mode 100644 index 00000000000..4ea72561282 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsldoi_merge.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-options "-O2 -mvsx" } */ + +#include "altivec.h" + +vector signed int test1 (vector signed int a, vector signed int b) +{ + a = vec_sld (a, b, 2); + a = vec_sld (a, a, 4); + return a; +} + +vector signed int test2 (vector signed int a, vector signed int b) +{ + a = vec_sld (a, b, 14); + a = vec_sld (a, a, 2); + return a; +} + +/* { dg-final { scan-assembler-times {\mvsldoi\M} 1 } } */