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 086F2385742F for ; Tue, 6 Sep 2022 14:01:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 086F2385742F 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.5/8.17.1.5) with ESMTP id 286DoU65026872 for ; Tue, 6 Sep 2022 14:01:58 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=N7DKhTCQr8M0zjzv9wYeNj2fLl1aBngBhX3vkY4Uku0=; b=Y7bMe9a4A0+LuYBZn/srHdX4AOdxh9nrxHfstP31VRP++kWfbQICgyqP9q7E9/okLbKF UERwSL6nSlTC5dOKIPus1hd5/OWBWIG1Y3PAzeZEI8swkPxI+cfH7511JHtCSFKlkDRM s1qsKPK393oSNcbUkFEX+qWJbQmnlBSrcaE7+tB06z6W1o4z18n7DxqXt8/TLDWKOKgJ Oma7y7ZDmLcXsHysgo91LZlQIgJisc/jyQxniTVsu0N/N+6o0wvRHyuysxKlOsY+cSwR E3AEZFZlbrmKROYieQuzyxDCaXO/yOX1YD7/a99OoZuS4nX7a+45XXDhNv7qLaQUCiL8 BA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3je7errdnj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 06 Sep 2022 14:01:57 +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 286Dq9N3001984 for ; Tue, 6 Sep 2022 14:01:57 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 3je7errdm7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 14:01:57 +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 286Dprbg005169; Tue, 6 Sep 2022 14:01:55 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma02fra.de.ibm.com with ESMTP id 3jbxj8tu72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 14:01:55 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 286E1ruC38666516 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Sep 2022 14:01:53 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F28D811C054; Tue, 6 Sep 2022 14:01:52 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BFE6211C052; Tue, 6 Sep 2022 14:01:52 +0000 (GMT) Received: from [9.171.63.5] (unknown [9.171.63.5]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 6 Sep 2022 14:01:52 +0000 (GMT) Message-ID: <938fbb10-926f-a588-1e90-1d7b72d1d7f8@linux.ibm.com> Date: Tue, 6 Sep 2022 16:01:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] expand: Convert cst - x into cst xor x. Content-Language: en-US To: Richard Biener Cc: GCC Patches , Andrew Pinski References: 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: V3qk5StHgsIGn9xHwnh_mHcI-f1X1p-p X-Proofpoint-ORIG-GUID: l_gkqxLEXRON-oWelAUmauRJZgBdl349 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-06_07,2022-09-06_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 mlxscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 spamscore=0 phishscore=0 mlxlogscore=745 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209060065 X-Spam-Status: No, score=-6.6 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,T_SCC_BODY_TEXT_LINE 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: > cost might also depend on the context in case flag setting > behavior differs for xor vs sub (on x86 sub looks strictly more > powerful here). The same is probably true when looking for > a combination with another bitwise operation. > > Btw, why not perform the optimization in expand_binop? That > for example already does > > if (binoptab == sub_optab && CONST_INT_P (op1)) > { > op1 = negate_rtx (mode, op1); > binoptab = add_optab; > } > > alternatively a targets expander can do the selection as well. I was under the impression optabs/expand_binops is only supposed to "optimize" when it's clear that it is an optimization/canonicalization. I didn't see other functions there trying two alternatives and also none seems to use range information already. Regarding the proper costing (including the surroundings): is it even possible to encompass everything in such a localized decision? A target's expander decision would also not take this into account when deciding? If so, should we not perform this conversion generally and not only target specifc? Regards Robin