From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id 00DD23858C60 for ; Thu, 2 Feb 2023 11:57:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00DD23858C60 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-x33.google.com with SMTP id 586e51a60fabf-16332831ed0so2075951fac.10 for ; Thu, 02 Feb 2023 03:57:21 -0800 (PST) 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 :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=FY1xfeWkuVjYDZPK4CLxGWZd9KL8BYrNcWVSXODg4nM=; b=hk4Xl2+hoIt3xGyLDZDvlZhkiP26/So/qRRNoq2nKggxW8brLId7HwwiBoPIMq9i8U y3nzPnzm4fTNszApQ4GbFKKhY7f8pITuBq8FEvhB8jCZorF2otpNOD34/5YkbdniLAzR FEidYVfV7aust3W0mzv6wWAF6g6GIDIsKyylINwQk5yDe+k40mkXYlZuZHzO7rtE0aqc CEB4DRrycOaK72WqPsIctu6eoH/fNMCcs15K6BAU++yK27xmjS1qTBTumZg25nm/Y8AN AdlI+VSR6rEmRQ47hLSm9+inAKojhRXCHZ3i05G6XXzFkXmMbPIvC+4WYzHQWywZFdOP QTow== 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 :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=FY1xfeWkuVjYDZPK4CLxGWZd9KL8BYrNcWVSXODg4nM=; b=36jL5vA0W+auHz7LonZVGqz/f911WPsZix3QTfg2I3/1L9cv3X568Uf1SC6DoHBhSj sZ8yzNxZ10Fjepi5DPyiTBCN7ThNcpp/Gc35eVkwOaeqI1gma8RlBwrvrpHqySyxs2XC AZOxtgOr9XmCsZfbHljTUkmygUqvd0vn82B8S57hKqRUEm2OmMKlmn4pRgVE8pXhudxN awfOJPgLshjIJ1bjZYsQ8FHhfb9cyi/6DB4vl56xaUlhb7wSL1h0pBx0XFtUfcNLOJPG Ue6WuO31NzN31BDa2J/GX+QCJuNOJlpjgDzNzTHAFQJpTceAkKZ/QvRisEnYvX9n9F2Z knVQ== X-Gm-Message-State: AO0yUKWsUcT1v6wf6x0cwp4PxXHlhdrs1I3IySd1Uhz5zc2Uw/d3ELQx aQz2H82cb4VzC5MoMpJNBZcVIQ== X-Google-Smtp-Source: AK7set+skUW6pNaxrc1PlOGbxA58IaHhdxS2PeGTjBHYKpwaNTFTKJ/Ik3aYGhVHUkGlhvGX0q8P5A== X-Received: by 2002:a05:6870:5b89:b0:169:cbcc:25b6 with SMTP id em9-20020a0568705b8900b00169cbcc25b6mr869131oab.4.1675339041264; Thu, 02 Feb 2023 03:57:21 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c2:1887:5d31:5c36:95c5:9e2e? ([2804:1b3:a7c2:1887:5d31:5c36:95c5:9e2e]) by smtp.gmail.com with ESMTPSA id j3-20020a4a8883000000b004f28d09a880sm8406094ooa.13.2023.02.02.03.57.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Feb 2023 03:57:20 -0800 (PST) Message-ID: <03c17f6e-964e-6a67-2c9d-134999f70fd6@linaro.org> Date: Thu, 2 Feb 2023 08:57:17 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.7.0 Subject: Re: [PATCH v11 08/29] string: Improve generic strcmp Content-Language: en-US To: Richard Henderson , libc-alpha@sourceware.org, Noah Goldstein , Jeff Law , Xi Ruoyao References: <20230201170406.303978-1-adhemerval.zanella@linaro.org> <20230201170406.303978-9-adhemerval.zanella@linaro.org> <49fb3200-6556-e711-72c1-f201d81c467c@linaro.org> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <49fb3200-6556-e711-72c1-f201d81c467c@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,BODY_8BITS,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 01/02/23 14:34, Richard Henderson wrote: > On 2/1/23 07:03, Adhemerval Zanella wrote: >> +static inline int >> +final_cmp (const op_t w1, const op_t w2) >> +{ >> +  /* It can not use index_first_zero_ne because it must not compare past the >> +     final '\0' is present (and final_cmp is called before has_zero check). >> +   */ > > "if present". > > And why is that?  Surely find_zero_ne_all will produce a true bit for the '\0' as advertised.  That will be either before or after the first ne, as advertised. > > Maybe there's some subtlety in index_first_zero_ne using find_zero_ne_low for little-endian, but I can't think of what it would be... Indeed find_zero_ne_low does not work for index_first_zero_ne on little-endian, but find_zero_ne_all does. So using: static inline int final_cmp (const op_t w1, const op_t w2) { unsigned int idx = index_first_zero_ne (w1, w2); return extractbyte (w1, idx) - extractbyte (w2, idx); } Works on both LE and BE, although I am not sure is the best option (compared to loop). I will use it anyways, we can tune it later.