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 D52DD3858D32 for ; Thu, 13 Apr 2023 07:59:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D52DD3858D32 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 (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33D6gMnr029390; Thu, 13 Apr 2023 07:59:28 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=NytlDXTITwT22yT+TqBPKyUSVtI6ZWspRuY5NJLFAbc=; b=NMONPGW2In1rwtQ85ivmL+eD0Lha9O6KCOs/ENib6DUWHlcLXOSr0J12JCcG+F+N0Y/B P3zhq3+ZgyFM89Db2ZMBqyiR1Gw3KBKaXcdc/zmThXCsq/ZKjdgY7gYC53fWpitEzpq+ mb7YjjI+yJklDC2dxN+CTb8sP8WbXBoLsdbgKDKeB0KEfePC2nSySZt0/cv0kqAk82pF xEAbxCYJjVnYv0Cdi8Vthq6dS06lm7Z8pGV27KVpbd85RV7SWdSaJKS2c7a2C8alAqgY 2yqd3CHleqTZSnkEIcNyuL1WHR7cA3BVd/WWzQ32ZSv/FXes3o4vlvl6Bl3uJRkLQatM Tg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pxcpvjvs5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Apr 2023 07:59:27 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33D6hdcE003645; Thu, 13 Apr 2023 07:59:27 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 3pxcpvjvqv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Apr 2023 07:59:27 +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 33D3jkox022381; Thu, 13 Apr 2023 07:59:24 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3pu0m1auxm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Apr 2023 07:59:24 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 33D7xKKd62128572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 13 Apr 2023 07:59:21 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 925C320113; Thu, 13 Apr 2023 07:29:39 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00BE82010E; Thu, 13 Apr 2023 07:29:37 +0000 (GMT) Received: from [9.177.24.145] (unknown [9.177.24.145]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 13 Apr 2023 07:29:36 +0000 (GMT) Message-ID: <0fb64ee1-1bf6-2a5f-4214-7567af5facbd@linux.ibm.com> Date: Thu, 13 Apr 2023 15:29:35 +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] VECT: Add WHILE_LEN pattern for decrement IV support for auto-vectorization Content-Language: en-US To: =?UTF-8?B?6ZKf5bGF5ZOy?= Cc: gcc-patches , Jeff Law , rdapp , "richard.sandiford" , rguenther References: <20230407014741.139387-1-juzhe.zhong@rivai.ai> <63723855B0BF2130+2023041120125573846623@rivai.ai> <139DA38AFC9CA5B5+2023041216004591287739@rivai.ai> <8D9731A1540E082A+202304122122129793085@rivai.ai> From: "Kewen.Lin" In-Reply-To: <8D9731A1540E082A+202304122122129793085@rivai.ai> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 2pZDy2SRURke_SbUcFjlgxSGO_abHw4B X-Proofpoint-GUID: xV2McQlvw6L21iUaG_K5Tzr3O0Sbyk2w X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-13_04,2023-04-12_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 malwarescore=0 phishscore=0 mlxlogscore=545 mlxscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 spamscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304130068 X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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 Juzhe, on 2023/4/12 21:22, 钟居哲 wrote: > Thanks Kewen.  > > It seems that this proposal WHILE_LEN can help s390 when using --param vect-partial-vector-usage=2 compile option. > Yeah, IMHO, the previous sequence vs. the proposed sequence are like: int foo (int *__restrict a, int *__restrict b, int n) { if (n <= 0) return 0; int iv = 0; int len = MIN (n, 16); int sum = 0; do { sum += a[len] + b[len]; iv += 16; int n1 = MIN (n, iv); // line A int n2 = n - n1; len = MIN (n2, 16); } while (n > iv); return sum; } vs. int foo (int *__restrict a, int *__restrict b, int n) { if (n <= 0) return 0; int len; int sum = 0; do { len = MIN (n, 16); sum += a[len] + b[len]; n -= len; } while (n > 0); return sum; } it at least saves one MIN (at line A) and one length preparation in the last iteration (it's useless since loop ends). But I think the concern that this proposed IV isn't recognized as simple iv may stay. I tried to compile the above source files on Power, the former can adopt doloop optimization but the latter fails to. > Would you mind apply this patch && support WHILE_LEN in s390 backend and test it to see the overal benefits for s390 > as well as the correctness of this sequence ?  Sure, if all of you think this approach and this revision is good enough to go forward for this kind of evaluation, I'm happy to give it a shot, but only for rs6000. ;-) I noticed that there are some discussions on withdrawing this WHILE_LEN by using MIN_EXPR instead, I'll stay tuned. btw, now we only adopt vector with length on the epilogues rather than the main vectorized loops, because of the non-trivial extra costs for length preparation than just using the normal vector load/store (all lanes), so we don't care about the performance with --param vect-partial-vector-usage=2 much. Even if this new proposal can optimize the length preparation for --param vect-partial-vector-usage=2, the extra costs for length preparation is still unavoidable (MIN, shifting, one more GPR used), we would still stay with default --param vect-partial-vector-usage=1 (which can't benefit from this new proposal). BR, Kewen