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 25DEC3854141 for ; Fri, 21 Oct 2022 09:14:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 25DEC3854141 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 (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29L98i0B001608 for ; Fri, 21 Oct 2022 09:14:03 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=nVHcMX2Jm/PVdnkUzKPCYEORkrOjlgENP/YDiFa3m7g=; b=LCspEjsuKUZjvhyeVGujEeuJPoH+mWte6q+BeP3bIAPQEwvvpt1fzE+N/4Ig/cipfIQW 6/4+RI62Krtr/V8mvcFUg9LjCy7GCF8DRt9BR6ojf8EkaS+YNyHrD/0yIjQqQEZiMjsN +wGw6LLcyU8x6PVqTdIQ+jlzxvCJ/rzaWIDCSX6Xht0ocLCPO1Gn9K9ie39kpQ/6rKE9 tt8Rb1dmQYaZ5GHZznAIjRwpSz/bxXFIT2iSYItR2shBacyChDnum58xKoe+p4nzZAXC yBcXXwkguDBcHudnOS17slOTZ5oph4orm4WZUwKN7MpfYVxSnPfOjBOt9Tt/WA0sAwcb Hw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kbr9u8gn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 21 Oct 2022 09:14:03 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29L99Wq5004450 for ; Fri, 21 Oct 2022 09:14:02 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kbr9u8gmm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Oct 2022 09:14:02 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29L96ELO017228; Fri, 21 Oct 2022 09:14:00 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma02fra.de.ibm.com with ESMTP id 3k7mg97qb3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Oct 2022 09:14:00 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29L9Dwkv2491018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Oct 2022 09:13:58 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 35C3C11C050; Fri, 21 Oct 2022 09:13:58 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E7E6311C04A; Fri, 21 Oct 2022 09:13:57 +0000 (GMT) Received: from [9.171.59.90] (unknown [9.171.59.90]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 21 Oct 2022 09:13:57 +0000 (GMT) Message-ID: <21949711-b310-cec3-5317-480c55f36ba5@linux.ibm.com> Date: Fri, 21 Oct 2022 11:13:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH] expand: Convert cst - x into cst xor x. To: Richard Biener Cc: GCC Patches , Andrew Pinski References: <938fbb10-926f-a588-1e90-1d7b72d1d7f8@linux.ibm.com> <3d928191-a2f5-f314-c03b-d4e590282ce9@linux.ibm.com> Content-Language: en-US From: Robin Dapp In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 21NWA1yLB94PfbS5tG3_nJnsTWvf10oY X-Proofpoint-ORIG-GUID: ujJzKtpBi7h0r6NBa9NSq72h-jRCJTeM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-21_03,2022-10-20_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=0 clxscore=1015 mlxlogscore=774 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210052 X-Spam-Status: No, score=-4.4 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: > Do we have evidence that targets properly cost XOR vs SUB RTXen? > > It might actually be a reload optimization - when the constant is > available in a register use 'sub', when it needs to be reloaded > use 'xor'? > > That said, I wonder if the fallout of changing some SUB to XOR > is bigger than the benefit when we do it early (missed combines, etc.)? Regarding fallout I did a bootstrap and regtest for various backends now. No change on Power9, s390x and aarch64. On x86 there is one additional FAIL in pr78103-3.c: unsigned long long bar (unsigned int x) { return __CHAR_BIT__ * sizeof (unsigned int) - 1 - __builtin_clz (x); } is supposed to become bsrl %edi, %eax ret but now is bsrl %edi, %eax xorl $31, %eax xorq $31, %rax ret The x86 backend has various splitters catching and simplifying something like (xor (minus (const_int 63) (clz (match_operand))) (const_int 63)) to (bsr ...). >From a quick glance, there are several combinations of 31, 63, xor, clz which would need to be duplicated(?) to match against the changed patterns. Perhaps xor is always cheaper on x86 and a simple change from (minus (const_int 63) (...)) to (xor (const_int 63) (...)) would be sufficient but this would still need to be reviewed separately. Needing to keep both patterns (as neither minus nor xor can be considered "more canonical" than the other) seems like an annoyance. Regards Robin