From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id A8A62385223F for ; Thu, 17 Nov 2022 21:59:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A8A62385223F 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-pl1-x62a.google.com with SMTP id io19so2876701plb.8 for ; Thu, 17 Nov 2022 13:59:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=1UN2Ttboa24K+W2RvqHzdvaISTEB2hcmfEEPkhVwyhk=; b=olQbS2EMKqiH/raG1mXcyjg/OJYdUjJ6fH9WHs8K6kaTHzNAtyg85MAeHZThBxyE0d 3qVT87BcQ7hY7z/tjqGoSzJxLLqWTiMwVz0SQyOosuvZVT2FAeCq4oc3lP+ogtCigBNc jC7gtL5Fsb4qlwxVyE4yzjGTRS8QJ/1M4REzkvKT0jd0HiPKifWubm2cxoUsGWUYG9ZU MmhnZHzpLJiwyilUmID1DypAqwVFAdX7xI2o3ek93eVj4cQ0JKqNl4Z+7Id+sEHu5Rku bbwPOQnQfRWpqiBRFabhIa63FU6h/K4hCLorfEV5q+ni4M3COsOPcUSgqrsNCUWrAdsN LZtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=1UN2Ttboa24K+W2RvqHzdvaISTEB2hcmfEEPkhVwyhk=; b=SMnI3Yzjy2O5sO1GkP8Ejr2mL6UgFnatRZ+03Ujfpw7BtgCbvlrvxOuyHd0LcZRdVL dV6sA8hi6SvOrPqZUSyNi31C/+0L1yWsJcUiYS3z25K4TbEm172YZgG17T1yEhQywklR ANs7x7lwvJwlIS/Xq1TDXRyq8njZnVv7Z246bwS4YUFvg03ObpFbObWbBWqt7Pe/O4bP uQMl7DnOw4RM3+9rnSxTXHqiCebbaZwCUGwTVGWDSI0ho4yBvtbeO1TBJTqi7k3PxZbC hDeOtWiDsli8YvPgvVsM8qmHnEY/7GrXq8Q9aarqF2mCIA3gQmAxP+aEypswSMqh2ZXX e8Yg== X-Gm-Message-State: ANoB5pm1Ugh339KvDLE6nURd8Q/OdIEAabkx1qEyHu1kD9GHXrnw1H0e 5qznIiIM677TbNcE7HvlPpzSTt4oX/Y= X-Google-Smtp-Source: AA0mqf4FKFyK5Euo8nMEyGlu4a2IYV3EZG0A13w50Dj3zPZT0nz4oN4ZCmL8RdC36pchdbP01LQhhA== X-Received: by 2002:a17:902:b697:b0:186:880c:167a with SMTP id c23-20020a170902b69700b00186880c167amr4470250pls.165.1668722372676; Thu, 17 Nov 2022 13:59:32 -0800 (PST) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id t15-20020a170902b20f00b00188ef2314b0sm1901743plr.39.2022.11.17.13.59.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Nov 2022 13:59:31 -0800 (PST) Message-ID: <17cfa5ef-511e-5d74-157f-498a9757e87d@gmail.com> Date: Thu, 17 Nov 2022 14:59:30 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH] match.pd: rewrite select to branchless expression Content-Language: en-US To: Andrew Pinski , Michael Collison Cc: gcc-patches@gcc.gnu.org, Jeff Law , "jakub@redhat.com >> Jakub Jelinek" References: 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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: On 11/8/22 13:15, Andrew Pinski via Gcc-patches wrote: > On Tue, Nov 8, 2022 at 12:02 PM Michael Collison wrote: >> This patches transforms (cond (and (x , 0x1) == 0), y, (z op y)) into >> (-(and (x , 0x1)) & z ) op y, where op is a '^' or a '|'. It also >> transforms (cond (and (x , 0x1) != 0), (z op y), y ) into (-(and (x , >> 0x1)) & z ) op y. >> >> Matching this patterns allows GCC to generate branchless code for one of >> the functions in coremark. >> >> Bootstrapped and tested on x86 and RISC-V. Okay? > This seems like a (much) reduced (simplified?) version of > https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584411.html . > I have not had time for the last year to go through the comments on > that patch and resubmit it though. > It seems like you are aiming for one specific case in coremarks rather > than a more generic fix too. I'm fairly confident it was developed independently.  Michael did this transformation for LLVM and reached out to me a month or two ago for suggestions on the GCC implementation. My recollection is I suggested phi-opt or match.pd with a slight preference for phi-opt as I wasn't offhand sure if we'd have a form suitable for match.pd. THe pattern is just a conditional xor/ior with all is said and done.  While the inspiration comes from coremark, I don't think it's supposed to be specific to coremark. jeff