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 679E03896C3D for ; Thu, 17 Nov 2022 06:59:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 679E03896C3D 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 (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AH6uHNG003597; Thu, 17 Nov 2022 06:59:09 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=Ei/DhqLlN9Au4CfRW6BaKsm+VYWJMuEIRvZtQQF9KtQ=; b=YYJf7jtTiUQjMhJY4MI1PxWiI7mVyAKcWbL7lrUkVtzyQ+oIvPh4HJRvxIJBKlurhav7 5nb8mOE5TblzxlbC9JgxxujS8lAehTkbTi3rhsFY6jKM+R0g33qPbViCvBfklIs1rP2k Bb6v1SouFeaCwX+ItIXKWku8wObMozaaLUf7vYrLkXIa0/GF/W3hFSOoNX37R02nP7Om WijbCS1prjrmIS4abnqAecBfkWNAFQZMO8XHqmerpuQ4E8FMq/EXm0iZwn9tH+qD9mhs VIcMO3d6FznasqnIYgQfIFFVpfRgZ48Fnkel5ksEUD8BmJccKXcVAljZUHL0A1HFzANE UQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kwg4jg2v0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Nov 2022 06:59:09 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AH6we29017430; Thu, 17 Nov 2022 06:59:09 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kwg4jg2u4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Nov 2022 06:59:09 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AH6pmbA013860; Thu, 17 Nov 2022 06:59:07 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3kt348y39s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Nov 2022 06:59:07 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AH6x4fn65077678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Nov 2022 06:59:04 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EFB7AA404D; Thu, 17 Nov 2022 06:59:03 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 140AFA4040; Thu, 17 Nov 2022 06:59:02 +0000 (GMT) Received: from [9.200.44.147] (unknown [9.200.44.147]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 17 Nov 2022 06:59:01 +0000 (GMT) Message-ID: <30553cb3-35d0-c51b-ffc4-0f8a320bd1ed@linux.ibm.com> Date: Thu, 17 Nov 2022 14:59:00 +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 1/2] rs6000: Emit vector fp comparison directly in rs6000_emit_vector_compare Content-Language: en-US To: Segher Boessenkool Cc: GCC Patches , David Edelsohn , Peter Bergner , Michael Meissner References: <20221116184437.GW25951@gate.crashing.org> From: "Kewen.Lin" In-Reply-To: <20221116184437.GW25951@gate.crashing.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: x17mAIOaMG8Gq2hnbCtu469hqJCKfQdV X-Proofpoint-GUID: t1FbrYWA89ZCQQgFNQq1eiJUX3feX3gp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-17_03,2022-11-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 mlxscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211170048 X-Spam-Status: No, score=-4.3 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Segher, Thanks for the comments! on 2022/11/17 02:44, Segher Boessenkool wrote: > Hi! > > On Wed, Nov 16, 2022 at 02:48:25PM +0800, Kewen.Lin wrote: >> * config/rs6000/rs6000.cc (rs6000_emit_vector_compare_inner): Remove >> float only comparison operators. > > Why? Is that correct? Your mail says nothing about this :-( > > Is there any testcase that covers this, and that shows things still > generate the same code? > Sorry for the unclear description, I thought mistakenly that it's probably straightforward. With the change in this patch, all 14 vector float comparison operators (unordered/ordered/eq/ne/gt/lt/ge/le/ungt/unge/unlt/unle/uneq/ltgt) would be handled early in rs6000_emit_vector_compare. For unordered/ordered/ltgt/uneq, the new way is exactly the same as what we do in rs6000_emit_vector_compare_inner, it means there is no chance to get into rs6000_emit_vector_compare_inner with any of them. For eq/ge/gt, it's the same too, but they are shared with vector integer comparison, I just left them alone here. Just noticed we can remove ge safely too as it's guarded with !MODE_VECTOR_INT. For ne/ungt/unlt/unge/unle, rs6000_emit_vector_compare changes the code with reverse_condition_maybe_unordered and invert the result, it's the same as what we have in vector.md. ; unge(a,b) = ~lt(a,b) ; unle(a,b) = ~gt(a,b) ; ne(a,b) = ~eq(a,b) ; ungt(a,b) = ~le(a,b) ; unlt(a,b) = ~ge(a,b) Then eq/ge/gt on the right side would match the cases that were mentioned above. So we just need to focus on lt and le then. For lt, rs6000_emit_vector_compare swaps operands and the operator to gt, it's the same as what we have in vector.md: ; lt(a,b) = gt(b,a) , and further matches the case mentioned above. As to le, rs6000_emit_vector_compare tries to split it into lt IOR eq, and further handle lt recursively, that is: le = lt(a,b) || eq(a,b) = gt(b,a) || eq(a,b) actually this is worse than what vector.md supports: ; le(a,b) = ge(b,a) In short, the function rs6000_emit_vector_compare_inner is only called by twice in rs6000_emit_vector_compare, there is no chance to enter rs6000_emit_vector_compare_inner with codes unordered/ordered/ltgt/uneq any more, I think it's safe to make the change in function rs6000_emit_vector_compare_inner. Besides, the proposed way to handle vector float comparison can improve slightly for UNGT and LE handlings. I constructed a test case, compiled with option -O2 -ftree-vectorize -fno-vect-cost-model on ppc64le, which goes into this function rs6000_emit_vector_compare with all 14 vector float comparison codes, the assembly of most functions doesn't change after this patch, excepting for test_UNGT_{float,double} and test_LE_{float,double}. one example from before: lxvx 12,3,9 lxvx 11,4,9 xvcmpgtsp 0,11,12 xvcmpeqsp 12,12,11 xxlor 0,0,12 xxlandc 0,32,0 stxvx 0,5,9 addi 9,9,16 bdnz .L77 vs. after: (good to be unrolled) lxvx 0,4,10 lxvx 12,3,10 addi 9,10,16 lxvx 11,3,9 xvcmpgesp 12,0,12 lxvx 0,4,9 xvcmpgesp 0,0,11 xxlandc 12,32,12 stxvx 12,5,10 addi 10,10,32 xxlandc 0,32,0 stxvx 0,5,9 bdnz .L77 =============== $ cat test.h #define UNORD(a, b) (__builtin_isunordered ((a), (b))) #define ORD(a, b) (!__builtin_isunordered ((a), (b))) #define LTGT(a, b) (__builtin_islessgreater ((a), (b))) #define UNEQ(a, b) (!__builtin_islessgreater ((a), (b))) #define UNGT(a, b) (!__builtin_islessequal ((a), (b))) #define UNGE(a, b) (!__builtin_isless ((a), (b))) #define UNLT(a, b) (!__builtin_isgreaterequal ((a), (b))) #define UNLE(a, b) (!__builtin_isgreater ((a), (b))) #define GT(a, b) (((a) > (b))) #define GE(a, b) (((a) >= (b))) #define LT(a, b) (((a) < (b))) #define LE(a, b) (((a) <= (b))) #define EQ(a, b) (((a) == (b))) #define NE(a, b) (((a) != (b))) #define TEST_VECT(NAME, TYPE) \ __attribute__ ((noipa)) void test_##NAME##_##TYPE (TYPE *x, TYPE *y, \ int *res, int n) \ { \ for (int i = 0; i < n; i++) \ res[i] = NAME (x[i], y[i]); \ } =============== $ cat test.c #include "test.h" #define TEST(TYPE) \ TEST_VECT (UNORD, TYPE) \ TEST_VECT (ORD, TYPE) \ TEST_VECT (LTGT, TYPE) \ TEST_VECT (UNEQ, TYPE) \ TEST_VECT (UNGT, TYPE) \ TEST_VECT (UNGE, TYPE) \ TEST_VECT (UNLT, TYPE) \ TEST_VECT (UNLE, TYPE) \ TEST_VECT (GT, TYPE) \ TEST_VECT (GE, TYPE) \ TEST_VECT (LT, TYPE) \ TEST_VECT (LE, TYPE) \ TEST_VECT (EQ, TYPE) \ TEST_VECT (NE, TYPE) TEST (float) TEST (double) =============== Maybe it's good to add one test case with function test_{UNGT,LE}_{float,double} and scan not xvcmp{gt,eq}[sd]p. With the above explanation, does this patch look good to you? BR, Kewen