From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id DE8223846409 for ; Sat, 9 Jul 2022 16:09:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DE8223846409 Received: by mail-ot1-x32f.google.com with SMTP id l9-20020a056830268900b006054381dd35so1218182otu.4 for ; Sat, 09 Jul 2022 09:09:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=IgSN6EgUzBQmZR2VXkFjMyc8xXqdV8Inr8chUGv6DAQ=; b=ntSTmBzenAntDVv9eKjVZkz99xaZj5/agTSBWubslS4j2rhpIjela8Hun2m5V8Ns6t G3QcqCx/F3Vz+UjuwUuU0uFeK1wcYEM1HbIEdqaVPunyLQGQ5388U+D+VH4kCJYaeV3G emZjySrbnfOSXbu8U/ghMcpdTKepQ2wJ1W9Jjzrj2o+2+ihSjPXfsXw7Qyseag9cvfbI JUGf25uJkiB3pd/CtkMHiPw1qGm9UfszwDRQNwC2q2Bcoz0FBMF2E5LUt6BBYeTejdR0 b9NaqSPYOA05Li0jAAerdwRax66MhLkJmejUANWugqtvzl5qNzkHaYnYKEWLqFRplGwf 84zA== X-Gm-Message-State: AJIora+59ulaHj8qjbBFbOe3zOTMM4Z40/TxFlwUrxFbrsXyRxHlHNzn 2xr4dk3qgxn3RdOE7gsBixB3m0kpzU8= X-Google-Smtp-Source: AGRyM1udDhVSUtXQWsczfUxKiu8SdYdHX3ZcuG+LEQ2N/MCdqiNF+mBcjG5SxLEng6exKoidw836VQ== X-Received: by 2002:a05:6830:da:b0:61c:3f98:d4ec with SMTP id x26-20020a05683000da00b0061c3f98d4ecmr920056oto.261.1657382954867; Sat, 09 Jul 2022 09:09:14 -0700 (PDT) Received: from [172.31.0.204] (c-73-63-24-84.hsd1.ut.comcast.net. [73.63.24.84]) by smtp.gmail.com with ESMTPSA id a19-20020a9d4713000000b0061686c44200sm865494otf.50.2022.07.09.09.09.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Jul 2022 09:09:14 -0700 (PDT) Message-ID: <0f04131d-f4ea-2477-9429-81614edc2bbd@gmail.com> Date: Sat, 9 Jul 2022 10:09:13 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] match.pd: Add new bitwise arithmetic pattern [PR98304] Content-Language: en-US To: gcc-patches@gcc.gnu.org References: <20220707135935.2249978-1-sfeifer@redhat.com> From: Jeff Law In-Reply-To: <20220707135935.2249978-1-sfeifer@redhat.com> 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, NICE_REPLY_A, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2022 16:09:17 -0000 On 7/7/2022 7:59 AM, Sam Feifer via Gcc-patches wrote: > Hi! > > This patch is meant to solve a missed optimization in match.pd. It optimizes the following expression: n - (((n > 63) ? n : 63) & -64) where the constant being negated (in this case -64) is a power of 2 and the sum of the two constants is -1. For the signed case, this gets optimized to (n <= 63) ? n : (n & 63). For the unsigned case, it gets optimized to (n & 63). In both scenarios, the number of instructions produced decreases. > > There are also tests for this optimization making sure the optimization happens when it is supposed to, and does not happen when it isn't. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > PR tree-optimization/98304 > > gcc/ChangeLog: > > * match.pd (n - (((n > C1) ? n : C1) & -C2)): New simplification. > > gcc/testsuite/ChangeLog: > > * gcc.c-torture/execute/pr98304-2.c: New test. > * gcc.dg/pr98304-1.c: New test. OK.   I'm going to assume Red Hat's assignment covers you and/or you want to contribute under the DCO.    Going forward, if you're part of the tools team for Red Hat and expect to be contributing regularly, you'll probably want to get authenticated write access so that you can commit  approved changes (anyone on the team should be able to help with that). I'll go ahead and push this one to the trunk. Thanks, Jeff