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 BFC623AA9422 for ; Thu, 15 Jul 2021 08:04:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BFC623AA9422 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16F83sm7143320; Thu, 15 Jul 2021 04:04:20 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 39sc8kx0b7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Jul 2021 04:04:19 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 16F84Jce145630; Thu, 15 Jul 2021 04:04:19 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 39sc8kx09g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Jul 2021 04:04:19 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16F83OLr013308; Thu, 15 Jul 2021 08:04:16 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma05fra.de.ibm.com with ESMTP id 39q368h4hc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Jul 2021 08:04:16 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16F84DTi12190098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Jul 2021 08:04:13 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 39BEC42052; Thu, 15 Jul 2021 08:04:13 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28C794203F; Thu, 15 Jul 2021 08:04:10 +0000 (GMT) Received: from KewenLins-MacBook-Pro.local (unknown [9.197.236.160]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 15 Jul 2021 08:04:09 +0000 (GMT) Subject: Re: [PATCH v3] vect: Recog mul_highpart pattern To: Uros Bizjak Cc: Richard Biener , Richard Sandiford , Bill Schmidt , GCC Patches , Segher Boessenkool References: <0b72fa77-a281-35e6-34e3-17cf26f18bc1@linux.ibm.com> <46838de4-3d92-a270-e71a-73fbe923d306@linux.ibm.com> From: "Kewen.Lin" Message-ID: Date: Thu, 15 Jul 2021 16:04:07 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-GUID: zNdQt6ntp8ZdG4NX5KrqfTYwqFTGO9_s X-Proofpoint-ORIG-GUID: J4xpKETVaPKP7ckN8kJ7SB9AyjnMUwER Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-15_02:2021-07-14, 2021-07-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 suspectscore=0 impostorscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107150060 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: Thu, 15 Jul 2021 08:04:26 -0000 Hi Uros, on 2021/7/15 下午3:17, Uros Bizjak wrote: > On Thu, Jul 15, 2021 at 9:07 AM Kewen.Lin wrote: >> >> on 2021/7/14 下午3:45, Kewen.Lin via Gcc-patches wrote: >>> on 2021/7/14 下午2:38, Richard Biener wrote: >>>> On Tue, Jul 13, 2021 at 4:59 PM Kewen.Lin wrote: >>>>> >>>>> on 2021/7/13 下午8:42, Richard Biener wrote: >>>>>> On Tue, Jul 13, 2021 at 12:25 PM Kewen.Lin wrote: >>>> >>>>> I guess the proposed IFN would be directly mapped for [us]mul_highpart? >>>> >>>> Yes. >>>> >>> >>> Thanks for confirming! The related patch v2 is attached and the testing >>> is ongoing. >>> >> >> It's bootstrapped & regtested on powerpc64le-linux-gnu P9 and >> aarch64-linux-gnu. But on x86_64-redhat-linux there are XPASSes as below: >> >> XFAIL->XPASS: gcc.target/i386/pr100637-3w.c scan-assembler pmulhuw >> XFAIL->XPASS: gcc.target/i386/pr100637-3w.c scan-assembler pmulhuw >> XFAIL->XPASS: gcc.target/i386/pr100637-3w.c scan-assembler pmulhw >> XFAIL->XPASS: gcc.target/i386/pr100637-3w.c scan-assembler pmulhw > > These XFAILs should be removed after your patch. > I'm curious whether it's intentional not to specify -fno-vect-cost-model for this test case. As noted above, this case is sensitive on how we cost mult_highpart. Without cost modeling, the XFAILs can be removed only with this mul_highpart pattern support, no matter how we model it (x86 part of this patch exists or not). > This is PR100696 [1], we want PMULH.W here, so x86 part of the patch > is actually not needed. > Thanks for the information! The justification for the x86 part is that: the IFN_MULH essentially covers MULT_HIGHPART_EXPR with mul_highpart optab support, i386 port has already customized costing for MULT_HIGHPART_EXPR (should mean/involve the case with mul_highpart optab support), if we don't follow the same way for IFN_MULH, I'm worried that we may cost the IFN_MULH wrongly. If taking IFN_MULH as normal stmt is a right thing (we shouldn't cost it specially), it at least means we have to adjust ix86_multiplication_cost for MULT_HIGHPART_EXPR when it has direct mul_highpart optab support, I think they should be costed consistently. Does it sound reasonable? BR, Kewen > [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100696 > > Uros. > >> They weren't exposed in the testing run with the previous patch which >> doesn't use IFN way. By investigating it, the difference comes from >> the different costing on MULT_HIGHPART_EXPR and IFN_MULH. >> >> For MULT_HIGHPART_EXPR, it's costed by 16 from below call: >> >> case MULT_EXPR: >> case WIDEN_MULT_EXPR: >> case MULT_HIGHPART_EXPR: >> stmt_cost = ix86_multiplication_cost (ix86_cost, mode); >> >> While for IFN_MULH, it's costed by 4 as normal stmt so the total cost >> becomes profitable and the expected vectorization happens. >> >> One conservative fix seems to make IFN_MULH costing go through the >> unique cost interface for multiplication, that is: >> >> case CFN_MULH: >> stmt_cost = ix86_multiplication_cost (ix86_cost, mode); >> break; >> >> As the test case marks the checks as "xfail", probably it's good to >> revisit the costing on mul_highpart to ensure it's not priced more. >> >> The attached patch also addressed Richard S.'s review comments on >> two reformatting hunks. Is it ok for trunk? >> >> BR, >> Kewen >> ----- >> gcc/ChangeLog: >> >> * internal-fn.c (first_commutative_argument): Add info for IFN_MULH. >> * internal-fn.def (IFN_MULH): New internal function. >> * tree-vect-patterns.c (vect_recog_mulhs_pattern): Add support to >> recog normal multiply highpart as IFN_MULH. >> * config/i386/i386.c (ix86_add_stmt_cost): Adjust for combined >> function CFN_MULH.