From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 70F94386C58C for ; Sat, 9 Jul 2022 15:59:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 70F94386C58C Received: by mail-ot1-x333.google.com with SMTP id h19-20020a9d6f93000000b0061c1ad77d5fso1199510otq.6 for ; Sat, 09 Jul 2022 08:59:38 -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=S+X+8mIk5WLDhFzeQWhqSXv8CChJlmgP+xOWA+H13gs=; b=tu3D5HN3KKUlVaR354W9qckwh8RXcKX7QbE15ny8t7DQVnnXOIMY2qqX94rEHVFHp2 uYGlSPLHAY3qpUEnxqBiiisqgwfrvAOCRriqtub3ftKGvnSU9UU1Dhm+CW5T4etpO4ye XM+P8ohrVmAGfK8XYAdyCyOHgTDZITW06UJE7XCkxz+hLB/KpOKE+y375yAe/XvX1Zqh 666TL1ruO3OdlJ3w4swYgAHDlN6WeeZQy8F7wUZMkhd8cnYQNDGfeay3oArWTE/ElUv+ hi9UK/Iy+RxG9avbTvVYqkdbySbx2+Qncr8xjIN/u1JjNQL+v3C5UixKyqegs5Gd/hZf b7VA== X-Gm-Message-State: AJIora93nOyAot3rDJTga+z4+SGsK97L+k6AGh5lS8CZnN9jbqVDHsWR CjVk0TlG1MJYdaWVrkourld/1VhH688= X-Google-Smtp-Source: AGRyM1sq2tF357NaCE81jMvw/ni9E+NX4p/W5gyESem9FJNLFTfgNHqjRJ1PWJYRkHO0SEb42Ibc0w== X-Received: by 2002:a05:6830:3707:b0:61c:434a:e020 with SMTP id bl7-20020a056830370700b0061c434ae020mr562558otb.307.1657382377329; Sat, 09 Jul 2022 08:59:37 -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 em31-20020a0568705b9f00b000f5eb6b409bsm945507oab.45.2022.07.09.08.59.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Jul 2022 08:59:36 -0700 (PDT) Message-ID: <74183249-3937-af58-207f-ec41333384d2@gmail.com> Date: Sat, 9 Jul 2022 09:59:35 -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 v3] tree-optimization/95821 - Convert strlen + strchr to memchr Content-Language: en-US To: gcc-patches@gcc.gnu.org References: <20220620163536.2653437-1-goldstein.w.n@gmail.com> <20220621181215.2942551-1-goldstein.w.n@gmail.com> From: Jeff Law In-Reply-To: <20220621181215.2942551-1-goldstein.w.n@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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, 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 15:59:40 -0000 On 6/21/2022 12:12 PM, Noah Goldstein via Gcc-patches wrote: > This patch allows for strchr(x, c) to the replace with memchr(x, c, > strlen(x) + 1) if strlen(x) has already been computed earlier in the > tree. > > Handles PR95821: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95821 > > Since memchr doesn't need to re-find the null terminator it is faster > than strchr. > > bootstrapped and tested on x86_64-linux. > > PR tree-optimization/95821 > > gcc/ > > * tree-ssa-strlen.cc (strlen_pass::handle_builtin_strchr): Emit > memchr instead of strchr if strlen already computed. > > gcc/testsuite/ > > * c-c++-common/pr95821-1.c: New test. > * c-c++-common/pr95821-2.c: New test. > * c-c++-common/pr95821-3.c: New test. > * c-c++-common/pr95821-4.c: New test. > * c-c++-common/pr95821-5.c: New test. > * c-c++-common/pr95821-6.c: New test. > * c-c++-common/pr95821-7.c: New test. > * c-c++-common/pr95821-8.c: New test. Given Jakub's involvement to-date and the fact this touches tree-ssa-strlen.cc I think Jakub should have final ACK/NAK on this. jeff