From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id C3F663858C54 for ; Wed, 7 Jun 2023 23:11:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3F663858C54 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-pf1-x42a.google.com with SMTP id d2e1a72fcca58-652426346bbso4114471b3a.3 for ; Wed, 07 Jun 2023 16:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686179468; x=1688771468; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=qpI7BCYRuoqoPF1AoQcxWE8u/Xv36iFYuPAFioQXocc=; b=Z5014u24Fz88HqqUjGsWCmQLr5byVgFv2vugIE75ONyk/hF4jYYNR7pz5vRKZi7hg7 01qhPc/kB8e4WWPZE2gissbPQvTu1DYSTT69V9zNSKz3B9qROhfFRgvmMaqStQWCidAx 0OvZI8rAXwrISHwbrCt4a8njJbtTovo8sQoI+jdlK1fKpri2pkjBu/rHC7TeGSumET12 5ZmFnTnrrdKMbXMNliHGQRLbyVDFrf3Jc2G7wkDEyxvC4F+IWn6YuB8lEy3KpYD0qlKh GNgTXG1vsxu/ftDcMp5Vsqv2NTd1arhLwz79vky6NL62cTiAce86G0HUKpmy21SD1n37 tdwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686179468; x=1688771468; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qpI7BCYRuoqoPF1AoQcxWE8u/Xv36iFYuPAFioQXocc=; b=cmHYk+FX4zzl/p/F9Lrac3bEKgvnERS+Arij/HxQ5OOqortvjsgUf3UpxYlRSdDf2e tcdG+n8hnJ7+Kr7D0QdKA5J9xdsK2U495LNbx+wfT4KyUlffZEXauAjICyOQ7RpsdtFq Zz+fzoT8o/LYiU4wEDwFr+yzv7D2a2hVfFYDTA2KfzmSJ9qUPqb79sD+/F4MvaX5zS+/ StgiFRktLbOfN3S/NoEuZ0jAIjlYZNrx+OMPd0Pjnu7bX2BAxkXP26k++6w3y8qbo6wN yCqM9HAD2Q1FO3GOmxSk36quc7hWJPQ8V24N04iFQan/C9r1Fq/YQkcgvwE6gat3dBQy 0mwg== X-Gm-Message-State: AC+VfDwZWruQcSEtesQK4qFIjNwsTO/rIhCsQJ4zXtukD35By4WoCr30 PV9b8VyOyK07xCjPOo77Ld4= X-Google-Smtp-Source: ACHHUZ5Whoncgy0XNkYL0YkPVysxZEMYJ8h/TBvYpKt5KpbtWuJmG+GTPdFLhl8fSElcjxfh6Vb/3Q== X-Received: by 2002:a17:902:ab43:b0:1b2:3e8e:ff05 with SMTP id ij3-20020a170902ab4300b001b23e8eff05mr2362105plb.51.1686179467623; Wed, 07 Jun 2023 16:11:07 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id x17-20020a170902ea9100b0019c13d032d8sm18846plb.253.2023.06.07.16.11.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Jun 2023 16:11:07 -0700 (PDT) Message-ID: <3bfa36d2-7fff-164a-c74b-8c82300b8a68@gmail.com> Date: Wed, 7 Jun 2023 17:11:05 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH 2/3] Change the `zero_one ==/!= 0) ? y : z y` patterns to use multiply rather than `(-zero_one) & z` Content-Language: en-US To: Andrew Pinski Cc: Andrew Pinski , gcc-patches@gcc.gnu.org References: <20230607213217.3052696-1-apinski@marvell.com> <20230607213217.3052696-2-apinski@marvell.com> From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,PLING_QUERY,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 6/7/23 17:05, Andrew Pinski wrote: > On Wed, Jun 7, 2023 at 3:57 PM Jeff Law via Gcc-patches > wrote: >> >> >> >> On 6/7/23 15:32, Andrew Pinski via Gcc-patches wrote: >>> Since there is a pattern to convert `(-zero_one) & z` into `zero_one * z` already, >>> it is better if we don't do a secondary transformation. This reduces the extra >>> statements produced by match-and-simplify on the gimple level too. >>> >>> gcc/ChangeLog: >>> >>> * match.pd (`zero_one ==/!= 0) ? y : z y`): Use >>> multiply rather than negation/bit_and. >> Don't you need to check the types in a manner similar to what the A & -Y >> -> X * Y pattern does before you make this transformation? > > No, because the convert is in a different order than in that > transformation; a very subtle difference which makes it work. > > In A & -Y it was matching: > (bit_and (convert? (negate > But here we have: > (bit_and (negate (convert > Notice the convert is in a different location, in the `A & -Y` case, > the convert needs to be a sign extending (or a truncation) of the > negative value. Here we are converting the one_zero_value to the new > type so we get zero_one in the new type and then doing the negation > getting us 0 or -1 value. THanks for the clarification. OK for the trunk. jeff