From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id C01AD385841A for ; Wed, 7 Sep 2022 12:46:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C01AD385841A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x633.google.com with SMTP id z17so1991206eje.0 for ; Wed, 07 Sep 2022 05:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=xVbHg6QNVQ3XW5xlWRxUKV2ggV3ldSQ1Vj/uiCHwYcA=; b=gnTCS45347iGr0hTQ43XGleONyqP9EZX2HggeMavq/ywO4v9KVJgTVb0225QDu1Mnh MjjfIs6FxuXcH97ND8sRStuQQtqzD9wVBjNTPVhswZ7s+EvCioUZkrro+Asz4sJ1ambH hz+PKRBiLBfa4XVft7+1ghjgQOOhR+7DjyskfmDByQpWFKCbivMXDY48zLHvn1N9o0zF 7S2QoM2WrCBdYGUNlokE9aVdVk1vbat7CEwBqNn97V1P0kSormzPiCO3IiziZBy6EUVE UySFeSsdE/3k/72h+zRHeOkpXhkb3NtVl+wpHP9vybJgf9FGrDSsxdghJFj2uIz25WGc O4hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=xVbHg6QNVQ3XW5xlWRxUKV2ggV3ldSQ1Vj/uiCHwYcA=; b=z3HLSuHu4QGaP3HKigOcVZVGNDkWSUs5vbN30uV0kjRJk1qKV3xvJmskyAv7YwyFJH eHqqSuU1vlVk4YiOCSyeAbjbhpqtA8aKMrkOf3Zh358hlQs/312UYHVRJwMpuU5fWJ5c 9H6ZWRACO12+bs0TJ9g5YiwcQcaO+xtNEiNYl1WC9hMf2KAjlv4VTnz85mqwGuuODTXV nQJYhaauwcDVQ/nSfkikbH3qBt4yjRXVhE2ZR/EJFJT2Ep9+NtiNAhiRjA69zYb54Vqn DKMlPg/XZ+b2TkWrv+j4pe5almWag3Cde++SNMonvYRx2+SVi36Q3KnGrGMSerL95gNv Pe9g== X-Gm-Message-State: ACgBeo08TW0LKyL0aoFnZQZfXc75l4OHomFq47c1pgK69vdWEI86f9mj odw+rn8lXw0Q+GtME0iXilD5Gyy37t/Q2zipPu0= X-Google-Smtp-Source: AA6agR6kQ57Uw9aAn96FXpQmyV8UOcZpDtwhWygn8CHPCg94Gnq75U6eiPpyBB/0lTvat7+v8jHjpzb359VNWHrS6uA= X-Received: by 2002:a17:906:8a68:b0:741:56b2:af42 with SMTP id hy8-20020a1709068a6800b0074156b2af42mr2240113ejc.488.1662554763130; Wed, 07 Sep 2022 05:46:03 -0700 (PDT) MIME-Version: 1.0 References: <938fbb10-926f-a588-1e90-1d7b72d1d7f8@linux.ibm.com> <3d928191-a2f5-f314-c03b-d4e590282ce9@linux.ibm.com> In-Reply-To: <3d928191-a2f5-f314-c03b-d4e590282ce9@linux.ibm.com> From: Richard Biener Date: Wed, 7 Sep 2022 14:45:51 +0200 Message-ID: Subject: Re: [PATCH] expand: Convert cst - x into cst xor x. To: Robin Dapp Cc: GCC Patches , Andrew Pinski Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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: On Wed, Sep 7, 2022 at 2:20 PM Robin Dapp wrote: > > > The question is really whether xor or sub is "better" statically. I can't > > think of any reasons. On s390, why does xor end up "better"? > > There is an xor with immediate (as opposed to no "subtract from > immediate") which saves an instruction, usually. On x86, I think the > usual argument for xor is that it's shorter (if flags etc. are not needed). > > It's not that I don't want to implement it in the backend, just that I > understood the original PR in a way that it would make sense to have > this conversion available for more targets. If there are too many > confounding factors that prevent this situation from being statically > costed properly, then sure, not much use in implementing it generally. 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.)? > Regards > Robin