From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 6A4BD3858D28 for ; Wed, 18 Jan 2023 02:10:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A4BD3858D28 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-pl1-x62d.google.com with SMTP id jl3so378411plb.8 for ; Tue, 17 Jan 2023 18:10:36 -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=sEEeKfurUOyOHyYxJOgWFSH661eZ5QXMJgUwVuKUjOA=; b=KarniCFpR1L0zeop7u10JspRauEhlQc8SDErxthJ12gD1ukCZzi7cPTXAfFCRNyljy FgloHwpld12rfabTi3+kVtFf3lXNRpp8HbRjlnPnjNrVOGCZcysSHDmgUlYwlfdbIPAE 4m55OgXKbTSpiG8WhElR43ggx73YwB1fqZfnqA0fHZnDrzmaVJxaaYwrzO1wdH+fDuAA Jkpu3FLX6BZd58+ltLDOmIWJOjKLxWcWLcDqoWkqE0cHzJQxCFZsdgH8il0UTFOd0Loi fdn1iznkQG2H3PPf8QvonDXbmBG0JTXjkR4EskUgc0+OrkFFjClGkzStbM4prNFI2xnv uNgA== 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=sEEeKfurUOyOHyYxJOgWFSH661eZ5QXMJgUwVuKUjOA=; b=RilT7p4TzjeVVxSJJWZe6rgtqpUYpaJCvn0KBZhJKN4A5qr3yW28HYiscTB772Zqhq kAafu/yK5XLJ0xASCk7+R+s4j/lwf6wTmXu9twaVSrXgkm5rqy22bB9CzbjVTAHEc44M y3KRCZo0VA5K1rOtfSng8IDHvn/xUzq2jCGXe4ESX6FJtha658LmUuIt5FXx8h3Wt3Xq vev+YZEWRKJGU9cWuXxTOfpLP92SbvCvfxoI6D35VixFYvUBkySNFNGwdGihIy5oOh9K eLU7PP1Zk3AJTi4VnBY+OA7XuX7a1vzqUmqwwBBa8Nqu632dRW6nCAqzrUDj05YIT86T QiUQ== X-Gm-Message-State: AFqh2kqXXCpHFXNpOj3ZfwSYnS5+lQidS05bLmhqxNQsxlAhGQ9urSjV P+gwCH/os6yEHDs2Ku5o4GZZMK0Yaj9+aXcp X-Google-Smtp-Source: AMrXdXssSXOfBpoJx/1fNtyALbbYLtK36NiYemI/dkPqWYadFdBe+4/3OgDoLKCXQwd0urmHpR1oHg== X-Received: by 2002:a17:902:cec8:b0:192:ef8e:4258 with SMTP id d8-20020a170902cec800b00192ef8e4258mr5987170plg.14.1674007835437; Tue, 17 Jan 2023 18:10:35 -0800 (PST) Received: from [192.168.5.146] (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id u6-20020a170902e80600b0019251e959b1sm21771936plg.262.2023.01.17.18.10.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Jan 2023 18:10:34 -0800 (PST) Message-ID: <04418ceb-0dc1-cdf9-82bd-6f1dbd2053b4@linaro.org> Date: Tue, 17 Jan 2023 16:10:31 -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 v9 10/22] string: Improve generic memrchr Content-Language: en-US To: Adhemerval Zanella , libc-alpha@sourceware.org, Noah Goldstein References: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> <20230117200014.1299923-11-adhemerval.zanella@linaro.org> From: Richard Henderson In-Reply-To: <20230117200014.1299923-11-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.6 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 1/17/23 10:00, Adhemerval Zanella wrote: > void * > +__memrchr (const void *s, int c_in, size_t n) > { > + if (__glibc_unlikely (n == 0)) > + return NULL; > > + const op_t *word_ptr = (const op_t *) PTR_ALIGN_UP (s + n, sizeof (op_t)); > + uintptr_t s_int = (uintptr_t) s + n; > > + op_t word = *--word_ptr; > + op_t repeated_c = repeat_bytes (c_in); > > + /* Compute the address of the word containing the initial byte. */ > + const op_t *sword = (const op_t *) PTR_ALIGN_DOWN (s, sizeof (op_t)); > > + if (s_int % sizeof (op_t) != 0) > { > + /* If the end of buffer is not op_t aligned, mask off the undesirable > + bits before find the last byte position. */ > + find_t mask = shift_find_last (find_eq_all (word, repeated_c), s_int); Ah, I see. Perhaps shift_find_last comment should indicate guaranteed misaligned? r~