From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 44A45385189B for ; Tue, 15 Nov 2022 01:55:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 44A45385189B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-lf1-x135.google.com with SMTP id b3so22269602lfv.2 for ; Mon, 14 Nov 2022 17:55:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XINfCxV4j6Lk01EGnauVAcrocKFjQCPrr9uHyy8DdPU=; b=gYC2SDDAHEDppllJfMIreMOH2gsaYod2O5WzZ7UA90oHxsQcj9ZkvDHBATDRkruWvV PbBFNTkIwDJ79y/NTvW5VoXl9bFyZZHdvux5GwBZCUt+YqduKSIzvmETgfupnaFFzZRM dgqvV/JAOwO906hKfagyVzyogC6/u/dOPZ+b/C4gDR6JH2LAdT8sCvUQhPmynHgT9Exq svDsLIekITNljR2kBSHz/4/H6dRVeFiiBxWiinCEIKZA7Rg289qfWMGuZ0get+xwuitP aIQZc1cCFDexqqS0aLiEQFM4J6R7ui/aYjUdx2vPvnczNkvBvS//4c0LyDpptR8+H3q1 bLtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XINfCxV4j6Lk01EGnauVAcrocKFjQCPrr9uHyy8DdPU=; b=wc1FASTxOq+Kmfz/PoDRCJgrHBclX5NFOMQy70nJqlFNjMQ7bjWiv27oCqudgLUaAL tIrkTRC4EIjEkDYoOggdpu72j+3RlM4kZD6N9pn7nd97nlVvZbL4Pnz4K/jSLJjNt4zW rbdVNbU2j80Zg1mjuj+FTE2cM5cKHeVs9zbql39YAMtPpERWEdyjvg+HGoM0cdf9NGXb yTRI9qDSHRpe+6/fZqQUjSUfCIEcOHNYWbU7m0NgRb7fknWRT/AYwrSiPIlSgHtxr/vY JHqquCRGQfXKfT5cvxAgzuTIhNclWZSzedVcR1uZv0JsVx5If+x+Jjm3dNCqfNmq/eRY 8q9Q== X-Gm-Message-State: ANoB5pnSK58vaNCmAg6MAJPCDe9sE/LgocFT0HTm3KJwSUhGqDeSxRLU NTHfZf08nEOBgCSLZ/t7jNP+mOMIhLWpD5D4IyMRsw== X-Google-Smtp-Source: AA0mqf5KzKNJCxCe8VwRHIGsYJEZJJ49NsxDo5smbZKTCeGzMQ3lsekW20z6k3norahzrGiJ/g8Sc3d1Iul19hXZnkY= X-Received: by 2002:a05:6512:348f:b0:499:b106:13eb with SMTP id v15-20020a056512348f00b00499b10613ebmr4668352lfr.242.1668477337165; Mon, 14 Nov 2022 17:55:37 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Kito Cheng Date: Tue, 15 Nov 2022 09:55:25 +0800 Message-ID: Subject: Re: [PATCH 7/7] riscv: Add support for str(n)cmp inline expansion To: Palmer Dabbelt Cc: Kito Cheng , christoph.muellner@vrull.eu, gcc-patches@gcc.gnu.org, Jim Wilson , Andrew Waterman , philipp.tomsich@vrull.eu, jeffreyalaw@gmail.com, Vineet Gupta Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Tue, Nov 15, 2022 at 8:53 AM Palmer Dabbelt wrote: > > On Mon, 14 Nov 2022 16:46:37 PST (-0800), Kito Cheng wrote: > > Hi Christoph: > > > >> This patch implements expansions for the cmpstrsi and the cmpstrnsi > >> builtins using Zbb instructions (if available). > >> This allows to inline calls to strcmp() and strncmp(). > >> > >> The expansion basically emits a peeled comparison sequence (i.e. a peeled > >> comparison loop) which compares XLEN bits per step if possible. > >> > >> The emitted sequence can be controlled, by setting the maximum number > >> of compared bytes (-mstring-compare-inline-limit). > > > > I would like to have a unified option interface, > > maybe -m[no-]inline-str[n]cmp and -minline-str[n]cmp-limit. > > And add some option like this: > > -minline-str[n]cmp=[bitmanip|vector|auto] in future, > > since I assume we'll have different versions of those things. > > Can we just decide that from mtune? We'll probably have uarch-specific > string functions at some point, might as well start planning for it now. I assume you mean the -minline-str[n]cmp=[bitmanip|vector|auto] part? I think this part should have more discussion and could defer that until we reach consensus. But -m[no-]inline-str[n]cmp and -minline-str[n]cmp-limit part I favor having those two options to disable and/or fine tune those parameters. > > >> gcc/ChangeLog: > >> > >> * config/riscv/riscv-protos.h (riscv_expand_strn_compare): New > >> prototype. > >> * config/riscv/riscv-string.cc (GEN_EMIT_HELPER3): New helper > >> macros. > >> (GEN_EMIT_HELPER2): New helper macros. > >> (expand_strncmp_zbb_sequence): New function. > >> (riscv_emit_str_compare_zbb): New function. > >> (riscv_expand_strn_compare): New function. > >> * config/riscv/riscv.md (cmpstrnsi): Invoke expansion functions > >> for strn_compare. > >> (cmpstrsi): Invoke expansion functions for strn_compare. > >> * config/riscv/riscv.opt: Add new parameter > >> '-mstring-compare-inline-limit'. > > > > We need to document this option.