From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id B291E3858D33 for ; Wed, 22 Feb 2023 10:49:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B291E3858D33 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 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31MAIvhX017994; Wed, 22 Feb 2023 10:48:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=pNMWXQDNTyMSQ70JzacQWcL6uGHottRGft56dkqpnhU=; b=JLrIVdVTJhm93V5VxowoJiR/z2yMaWVSACjdFBfV8TyuCfFQRmmNTZMjvxi0+7rDhJWc 5XGk8witqVeQkJALIBMZ2kzGpxlfa88J07php0DyDm1re5oink+CT7zrhf31EKs2E2aI NpzfWgQSDhQBlzoxx6y6LU0WtrcXi3yHJXlnZJh8wxERvoN6BiEDgjzQSYG2kmoHGBg0 BYPZ0wATI64RlBLYW6fvy40XeDJFQA+ce2Wdwh8Z22uLbSq6Qj4e4PcUzUuvAVr5Z2yS F7HR5ReMuT80PBmBep00hPPuaDJGzKHusIvxii2YSn3Z8APotTuTyl0jOPXvAKU4VjIy Vg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nwh6kgng7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Feb 2023 10:48:59 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31MALZkl025536; Wed, 22 Feb 2023 10:48:58 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nwh6kgnfj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Feb 2023 10:48:58 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31M08ej6019871; Wed, 22 Feb 2023 10:48:56 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3ntnxf57kc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Feb 2023 10:48:56 +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 31MAmqHx39846200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Feb 2023 10:48:53 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D866D20040; Wed, 22 Feb 2023 10:48:52 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E43B220049; Wed, 22 Feb 2023 10:48:50 +0000 (GMT) Received: from [9.197.242.224] (unknown [9.197.242.224]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 22 Feb 2023 10:48:50 +0000 (GMT) Message-ID: <0b35694d-e1ee-eb56-22c5-74f4f04afdd8@linux.ibm.com> Date: Wed, 22 Feb 2023 18:48:49 +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 Subject: Re: [PATCH, rs6000] Merge two vector shift when their sources are the same Content-Language: en-US To: HAO CHEN GUI Cc: Segher Boessenkool , David , Peter Bergner , gcc-patches References: <4005d148-ca54-880b-6c97-7f2fae15d8d1@linux.ibm.com> From: "Kewen.Lin" In-Reply-To: <4005d148-ca54-880b-6c97-7f2fae15d8d1@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 9mWxEwyKuLuxVnjMQVjLLDDSH09RLLev X-Proofpoint-ORIG-GUID: zqoV5LW6pcwL54d7JbFhn8MsSfwrc0B2 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-22_05,2023-02-22_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 phishscore=0 adultscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302220092 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,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 List-Id: Hi Haochen, on 2023/2/20 10:04, HAO CHEN GUI wrote: > 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; > +}) This patch looks wrong, I think we need to ensure operand 1 and operand 2 are the same (dup 1 for 2)? one simple counter example for this proposed fix is that two given vector a {A0, A1} and {B0, B1} (all A0/A1/B0/B1 are doublewords) on BE: a = vec_sld (a, b, 8); // (1) res a = {A1, B0} a = vec_sld (a, a, 8); // (2) res a = {B0, A1} it would get the unexpected result a {A0, A1} with this patch. Since this patch got bootstrapped and regress-tested, I think we don't have enough coverage on this part, it's a good thing to add one dg-do run test case as well. :) BR, Kewen