From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by sourceware.org (Postfix) with ESMTPS id 050583858D28 for ; Mon, 19 Sep 2022 19:17:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 050583858D28 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-oa1-x2b.google.com with SMTP id 586e51a60fabf-12c8312131fso842908fac.4 for ; Mon, 19 Sep 2022 12:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date; bh=nHUmpDV6PAdIIigsAiH0RxmuR/RZ5gSRdAaCxhjCzRA=; b=yxKruTGUNef78Wnb16o82Owx2FvMpEln2xqFkydnfth1yNCW6p0idc0d81SBfZjJZs DG+9+LhIKdYcAmIUA9UcGkJXqugIxCyHTT4B9wIApnup8P2PPpG82fvcJaV6i9Oall1E CN4+lEQNOEnljQMFiw29liMNks+8cfpEC2ukrW9DOvdtgjKztSDBtu1itnPFzgwENAqW b8RsxpEPu1OPMkfmym1t7/KuAf0O0fLpbm5AeSWmSpNKT/0Ov3SrzGtM3mQM1rSGVjqZ ngV/W9J62eSJX6RVxa3jT3ZeeohadQv3eXbXiVRGNSs+tmPtdGN+kLSwmf3T3kxtZbPf vOaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=nHUmpDV6PAdIIigsAiH0RxmuR/RZ5gSRdAaCxhjCzRA=; b=GfTvyCBWF+R6oGtPkgP3hufNkMsANlroW26Ra6cOqxO4d7YzQOrMk8OrZZfnZBQF9s DLIqWv542UxLncM49LrQWz1Bt1XCbUOeflBX4LZZSrVG1/4qXp9pycZ4eOlN6KLWJ3KU /vlsVWiJzxZplrD9H6SpcW6Y7vOSCyeGclUN0AjDAjYq+SxYZuAo4RtiyqtnIR0B6q3e zZsLYijFRc6MctwNgieR8D2IDc3I/ZvoXGOCtLG3PBXqTChB+tf5hUdryBhjdDk/rIqc B1t7vbLpGPVU4mlgWoW7kcduFaZT1iXzQaroVqc+Cmvc3JiQbOU1ef2SDjyAYRkmfupN VXAg== X-Gm-Message-State: ACrzQf2SCqBuOtb2wiSUw4ca+SlhTmf/lbxJeVjOkBH4UTjApcY/1xM9 KBjkQVmbU8RtXGRSfoG0RzjLaQ== X-Google-Smtp-Source: AMsMyM5JD/QJrQUczcY2LgPJDQ/GtJ3Zp2diZEouA+FdCbn8UWFi4iLdzMrXbzphBo9OgZ5PkKqUtA== X-Received: by 2002:a05:6870:d147:b0:126:d4a4:e99d with SMTP id f7-20020a056870d14700b00126d4a4e99dmr10523594oac.149.1663615023340; Mon, 19 Sep 2022 12:17:03 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c1:c266:6474:c804:752d:521c? ([2804:1b3:a7c1:c266:6474:c804:752d:521c]) by smtp.gmail.com with ESMTPSA id l4-20020a9d4c04000000b0065126423321sm13251472otf.76.2022.09.19.12.17.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Sep 2022 12:17:02 -0700 (PDT) Message-ID: <0358c009-eda0-ae01-5d63-69003e3fe375@linaro.org> Date: Mon, 19 Sep 2022 16:17:00 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 10/17] string: Improve generic memchr Content-Language: en-US To: Noah Goldstein Cc: GNU C Library , Richard Henderson , Joseph Myers , caiyinyu References: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> <20220902203940.2385967-11-adhemerval.zanella@linaro.org> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 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 03/09/22 00:47, Noah Goldstein wrote: >> >> - longword_ptr = (const longword *) char_ptr; >> + /* Compute the address of the word containing the last byte. */ >> + const op_t *lword = word_containing (lbyte); >> >> - /* All these elucidatory comments refer to 4-byte longwords, >> - but the theory applies equally well to any size longwords. */ >> + /* Read the first word, but munge it so that bytes before the array >> + will not match goal. */ >> + const op_t * word_ptr = word_containing (s); >> + op_t word = (*word_ptr | before_mask) ^ (repeated_c & before_mask); > > Why do you xor with repeated_c & before_mask here? > > Doesn't the has_eq(word, repeated_c) do that? For the case of c_in being 0xff, since for this case or with before_mask will make has_eq to return early. The test-memchr does not trigger it, but test-memccpy does fail without the XOR.