From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by sourceware.org (Postfix) with ESMTPS id 9B9AD3858C53 for ; Thu, 24 Aug 2023 17:21:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B9AD3858C53 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-x29.google.com with SMTP id 586e51a60fabf-1c0fa9dd74fso29460fac.3 for ; Thu, 24 Aug 2023 10:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692897689; x=1693502489; 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=XbmHAxmrU118GzrEE2imwlJxzD1ZfYiYz68i9zcvWUw=; b=tKHQhskeqnJBEM8HPbgGLMzwWccnUjoxbp3Qhq4nqD8ctnhCpquGJT9PUYwo33SXv7 ZAynuYQEWrxEL6j0+am/luvXouLH4Fo3e13BdWKv4BHJOnNUZkJ4XHJR+C3hsankTh5I 9BG/URG4w/j3vSo7p6uK9pnpbPEKC34ixlJ8MVVCDl+ksZfUuYB4YcG7UgezpWdtZNYO ye0rLQblivQcozC5Ly5PpKMMIJapob33oYa6NDrQO9hNN9yCdYGuKBYvRq6jMKgVzu1y BBEGOHIVarTnJS7Fi9UkiZIHgy8Kt4VaTRcMqYh1bwiJjIF6YEaJSuwbDla4Ttz1iYUN emzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692897689; x=1693502489; 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=XbmHAxmrU118GzrEE2imwlJxzD1ZfYiYz68i9zcvWUw=; b=BVW9xu/2mOBOAIo/Mmr9mjFFHx1ld+IzLettxd3GUggnjNDo7oFDn6zdpPRmIHCkTK 34U6J8wcgy1I4ayb7O9/2RWJ0q5wro8AOOmDM1bH+GuuJMOYfblxGYFmEgf5/UwzSDir ISBiqMDZMWT3n8m525zWWVoFdjVpqLW6an9E9XtE29flz0jSooaw+5D1DDgPQ8nNTT+G WI+U8VQXm6DUEP4uh/B2afcMx1UzwZzRw2K3t3bJCj1jorc2kc04/0egUrgpGT1DAa9w YlodtnEw4y/oQPtjhNDD1FhBHx14uDEmbMwsjE22gH5Ba16HR5nevIAefMbGpFKeppyv GsZA== X-Gm-Message-State: AOJu0YxR2ISD6ffdFrUStD3ZJGiJxxP+CUu6ZE6MlqX9yfPn0W15gfxR oQ3t/6JDgm4tIWABxF/RTJV+TA== X-Google-Smtp-Source: AGHT+IEZahoCMFsZt6iTzdE+4TyAYyYj2dqmiMJIoNe+qHG3OvIZFEBNf1du40iP3YfeaiAebKoBSQ== X-Received: by 2002:a05:6870:648a:b0:1bf:1a58:c4f with SMTP id cz10-20020a056870648a00b001bf1a580c4fmr423485oab.55.1692897688790; Thu, 24 Aug 2023 10:21:28 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c2:c275:d8f:2562:4517:f8f5? ([2804:1b3:a7c2:c275:d8f:2562:4517:f8f5]) by smtp.gmail.com with ESMTPSA id s6-20020a05687087c600b001c518774ae6sm13366oam.15.2023.08.24.10.21.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Aug 2023 10:21:28 -0700 (PDT) Message-ID: Date: Thu, 24 Aug 2023 14:21:23 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH] riscv: Add support for XTheadBb in string-fz[a,i].h Content-Language: en-US To: Christoph Muellner , libc-alpha@sourceware.org, Palmer Dabbelt , Darius Rad , Andrew Waterman , Philipp Tomsich References: <20230823054628.1318615-1-christoph.muellner@vrull.eu> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20230823054628.1318615-1-christoph.muellner@vrull.eu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 23/08/23 02:46, Christoph Muellner wrote: > From: Christoph Müllner > > XTheadBb has similar instructions like Zbb, which allow optimized > string processing: > * th.ff0: find-first zero is a CLZ instruction. > * th.tstnbz: Similar like orc.b, but with a bit-inverted result. > > The instructions are documented here: > https://github.com/T-head-Semi/thead-extension-spec/tree/master/xtheadbb > > These instructions can be found in the T-Head C906 and the C910. > > Tested with the string tests. > > Signed-off-by: Christoph Müllner LGTM, thanks. Is th.tstnbz available as builtin by chance? Reviewed-by: Adhemerval Zanella > --- > sysdeps/riscv/string-fza.h | 7 ++++++- > sysdeps/riscv/string-fzi.h | 2 +- > 2 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/sysdeps/riscv/string-fza.h b/sysdeps/riscv/string-fza.h > index 4429653a00..4958d5d151 100644 > --- a/sysdeps/riscv/string-fza.h > +++ b/sysdeps/riscv/string-fza.h > @@ -19,7 +19,7 @@ > #ifndef _RISCV_STRING_FZA_H > #define _RISCV_STRING_FZA_H 1 > > -#ifdef __riscv_zbb > +#if defined __riscv_zbb || defined __riscv_xtheadbb > /* With bitmap extension we can use orc.b to find all zero bytes. */ > # include > # include > @@ -32,8 +32,13 @@ static __always_inline find_t > find_zero_all (op_t x) > { > find_t r; > +#ifdef __riscv_xtheadbb > + asm ("th.tstnbz %0, %1" : "=r" (r) : "r" (x)); > + return r; > +#else > asm ("orc.b %0, %1" : "=r" (r) : "r" (x)); > return ~r; > +#endif > } > > /* This function returns 0xff for each byte that is equal between X1 and > diff --git a/sysdeps/riscv/string-fzi.h b/sysdeps/riscv/string-fzi.h > index 8f56c378ff..45d6367a10 100644 > --- a/sysdeps/riscv/string-fzi.h > +++ b/sysdeps/riscv/string-fzi.h > @@ -19,7 +19,7 @@ > #ifndef _STRING_RISCV_FZI_H > #define _STRING_RISCV_FZI_H 1 > > -#ifdef __riscv_zbb > +#if defined __riscv_zbb || defined __riscv_xtheadbb > # include > #else > /* Without bitmap clz/ctz extensions, it is faster to direct test the bits