From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id A074B3858D3C for ; Fri, 9 Jul 2021 01:26:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A074B3858D3C Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16914AN5177416; Thu, 8 Jul 2021 21:26:48 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0b-001b2d01.pphosted.com with ESMTP id 39nrfhq2ew-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Jul 2021 21:26:48 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1691HjDR010411; Fri, 9 Jul 2021 01:26:47 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma03wdc.us.ibm.com with ESMTP id 39jfhdjp6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Jul 2021 01:26:47 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1691QkDo11338482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Jul 2021 01:26:46 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CCD6EAE060; Fri, 9 Jul 2021 01:26:46 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6BF22AE05F; Fri, 9 Jul 2021 01:26:46 +0000 (GMT) Received: from [9.65.201.128] (unknown [9.65.201.128]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 9 Jul 2021 01:26:46 +0000 (GMT) Subject: Re: rs6000: Generate an lxvp instead of two adjacent lxv instructions To: Segher Boessenkool Cc: GCC Patches References: <20210708232836.GT1583@gate.crashing.org> From: Peter Bergner Message-ID: <680c1d6a-0662-f609-f0b5-2547011ea4b6@linux.ibm.com> Date: Thu, 8 Jul 2021 20:26:45 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210708232836.GT1583@gate.crashing.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ndvfB96wwIuhEBUfXxLMPE1wBbG270af X-Proofpoint-ORIG-GUID: ndvfB96wwIuhEBUfXxLMPE1wBbG270af X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-08_14:2021-07-08, 2021-07-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 adultscore=0 impostorscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107090003 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Fri, 09 Jul 2021 01:26:49 -0000 On 7/8/21 6:28 PM, Segher Boessenkool wrote: > It needs testing on BE. Will do. >> +static bool consecutive_mem_locations (rtx, rtx); > > Please don't; just move functions to somewhere earlier than where they > are used. Will do. >> @@ -16841,8 +16843,35 @@ rs6000_split_multireg_move (rtx dst, rtx src) >> for (int i = 0; i < nvecs; i++) >> { >> int index = WORDS_BIG_ENDIAN ? i : nvecs - 1 - i; >> - rtx dst_i = gen_rtx_REG (reg_mode, reg + index); >> - emit_insn (gen_rtx_SET (dst_i, XVECEXP (src, 0, i))); >> + int index_next = WORDS_BIG_ENDIAN ? index + 1 : index - 1; > > What does index_next mean? The machine instructions do the same thing > in any endianness. Yeah, I'm bad at coming up with names! :-) So "index" is the index into XVECEXP (src, 0, ...) which is the operand that is to be assigned to regno. "index_next" is the index into XVECEXP (src, 0, ...) which is the operand to be assigned to regno + 1 (ie, the next register of the even/odd register pair). Whether the "next index" is index+1 or index-1 is dependent on LE versus BE. >> + /* If we are loading an even VSX register and our memory location >> + is adjacent to the next register's memory location (if any), >> + then we can load them both with one LXVP instruction. */ >> + if ((regno & 1) == 0 >> + && VSX_REGNO_P (regno) >> + && MEM_P (XVECEXP (src, 0, index)) >> + && MEM_P (XVECEXP (src, 0, index_next))) >> + { >> + rtx base = WORDS_BIG_ENDIAN ? XVECEXP (src, 0, index) >> + : XVECEXP (src, 0, index_next); >> + rtx next = WORDS_BIG_ENDIAN ? XVECEXP (src, 0, index_next) >> + : XVECEXP (src, 0, index); > > Please get rid of index_next, if you still have to do different code for > LE here -- it doesn't make the code any clearer (in fact I cannot follow > it at all anymore :-( ) We do need different code for LE versus BE. So you want something like if (WORDS_BIG_ENDIAN) {...} else {...} ...instead? I can try that to see if the code is easier to read. > So this converts pairs of lxv to an lxvp in only a very limited case, > right? Can we instead do it more generically? And what about stxvp? Doing it more generically is my next TODO and that will cover both lxvp and stxvp. My thought was to write a simple pass run at about the same time as our swap optimization pass to look for adjacent lxv's and stxv's and convert them into lxvp and stxvp. However, that won't catch the above case, since the assemble/build pattern is not split until very late, so we still want the above change. Also, given the new pass will be more complicated than the above code, it will be a GCC 12 only change. Let me make the changes you want and I'll repost with what I come up with. Peter