From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id 214EC3858C52 for ; Sat, 4 Feb 2023 03:07:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 214EC3858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pj1-x1034.google.com with SMTP id nm12-20020a17090b19cc00b0022c2155cc0bso6624008pjb.4 for ; Fri, 03 Feb 2023 19:07:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=0Oy/WjiPzzUGL77M/CIRNrrMPpsvl5DyhyI5qRzP1g0=; b=uyoYfajVURp/bMr03rd6LSdmwyrwMUF2c77Ei6gUeoRsTTUunxtFitCcOv/+ZvN8Fm 848C47+CKXCmNHsy2RjziZVlT6Q4B3uMU+Uiv7uYauept3xYPJ8TgxWL7+THNjYf84dB m28B6Qz3lsphT9HsQhbW9TRTLIvLzY9bT5wcMn0lqN65u0Clp5b0jRvkwoVneyi+ao/R QNgbbYQtPAVNdKbqvzB7rcFLzIpWrOKRd1cns1NnweTNT5MjEzbG31AQ0+AWpyyhsK54 CB0OxphvNoQfeO5t2myoKR5+P5U4FxBrLN2WgJewXfmwGSCgGgbxN+ijF3ydv6h6MuJF ccmg== 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: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=0Oy/WjiPzzUGL77M/CIRNrrMPpsvl5DyhyI5qRzP1g0=; b=K1u6b0hWolqpiOG8MMbEIRVa3fTAAa8Dw8PXVdEUhR+kGVRglRclthvKvL8zegqL7z HqodaL68jxjkvHqrUZTh05yBKn7ZOfRoZ/pGrbNnqtALPF6LpU+KXndU31s4lMFjdzCz 49xhE4CmQfB9r1IRGrL7iRMo2AS3lcuO5MODWV1v/5rdV4omAe78NjJUQQ8uuJilVpcD Q+B6/xdOhCsAkOTqYXjJsdHKg6CKkCYBwAY1veuaVY3CEq76HLoAWR6cO9ejRqgTevpt g+j+KGdUku/6whEXriUE9c8ncnmPJIlwlMLCSo53/WiC/ARPQxp/GC1+Ch3aGET8xNg/ YF3Q== X-Gm-Message-State: AO0yUKVfcUvv0ndUbHJx69M7IJWiXU0rflSLBBhNj269av/vHmjJApKh 9Gor1dsL1tW8cLlNhuQ6M9FVVQ== X-Google-Smtp-Source: AK7set+G9H7+kAAQ2qr1EbFVnvN/bp+cjMF2X/vNQpSOl77D3Gs2NFj9Xh6wo9A8O5wBfwu9DVrAuw== X-Received: by 2002:a17:902:d192:b0:198:ec78:c81d with SMTP id m18-20020a170902d19200b00198ec78c81dmr1600894plb.42.1675480019104; Fri, 03 Feb 2023 19:06:59 -0800 (PST) Received: from [192.168.50.177] (rrcs-173-197-98-118.west.biz.rr.com. [173.197.98.118]) by smtp.gmail.com with ESMTPSA id b11-20020a1709027e0b00b00198bfb25195sm2311242plm.80.2023.02.03.19.06.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Feb 2023 19:06:58 -0800 (PST) Message-ID: Date: Fri, 3 Feb 2023 17:06:55 -1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v12 14/31] string: Improve generic strrchr with memrchr and strlen Content-Language: en-US To: Adhemerval Zanella , libc-alpha@sourceware.org, Jeff Law , Xi Ruoyao , Noah Goldstein References: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> <20230202181149.2181553-15-adhemerval.zanella@linaro.org> From: Richard Henderson In-Reply-To: <20230202181149.2181553-15-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 2/2/23 08:11, Adhemerval Zanella wrote: > Now that both strlen and memrchr have word vectorized implementation, > it should be faster to implement strrchr based on memrchr over the > string length instead of calling strchr on a loop. > > Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu, > and powerpc64-linux-gnu by removing the arch-specific assembly > implementation and disabling multi-arch (it covers both LE and BE > for 64 and 32 bits). > --- > string/strrchr.c | 18 +----------------- > 1 file changed, 1 insertion(+), 17 deletions(-) memrchr needs libc_hidden_builtin_proto. On riscv64: c: 00000097 auipc ra,0x0 c: R_RISCV_CALL __GI_strlen c: R_RISCV_RELAX *ABS* 10: 000080e7 jalr ra # c <__GI_strrchr+0xc> ... 24: 00000317 auipc t1,0x0 24: R_RISCV_CALL_PLT __memrchr 24: R_RISCV_RELAX *ABS* 28: 00030067 jr t1 # 24 <.LVL2+0x8> r~