From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe36.google.com (mail-vs1-xe36.google.com [IPv6:2607:f8b0:4864:20::e36]) by sourceware.org (Postfix) with ESMTPS id AA1F73851897 for ; Tue, 15 Nov 2022 00:46:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AA1F73851897 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vs1-xe36.google.com with SMTP id a6so8995047vsc.5 for ; Mon, 14 Nov 2022 16:46:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4VNqHrC15tGUXAp/rBZfdybirOeS2DEHHbmLtqA1+KA=; b=fhQlX7gTankMFkrU96/J5pKmII6rBOZUKLIzXtEx7HkufTZnknTD2qq5AiUrRr2vyC zNh4a7ngj1Ms1GP0+DIvG73soTJ4kpOw8jgwCyeNlhPsQYAAYNNYrMtiVu48xc0UBFDv KkPOYxyjpDhFlRbqL13NJcs5WplQwOgJ9xJOWE/QnaqqLVQgBy7oYb2wvzbcat9b0rwo AxkU2nrExfJ8F3s5FgT/QIJvV9Q+RDmfYUyDJLVjKKK2glDq7UrJfXWAMGX1hQ25r2ut d8Yeo32zOxXaMgD/qj2agaVkluE33baEZ/5tgauyrxwHdf2ysmskHxWrLWrHdHAcPyng bjGQ== 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=4VNqHrC15tGUXAp/rBZfdybirOeS2DEHHbmLtqA1+KA=; b=gfnBdPQ6Yeu9W5Nqnfx7xyXTkbNkO/d/K3KkyGX7e0AwPbn410U0S2T0QZhUqqIG/7 Oc4oY5FEaF+2VGS0giZB/CX21VLIBWRNDTJ1K8weTgQ9FUZEPN9GEVCsIGx8oNeG8y/a Kgl5s8+zzqOZePt4NwPbwrQGR4biD2Ph7lgZVM5LBbNrMEgTre5d/TmrBxAs3srlsfYf IwiSWN/4txlHNtksoLZJ31rP/XwAXtnqISFVqb1L0xNhzYVErc/4LDst3WJqBzmW42qq D7Dvvuky10ZXzQ438JszyDlBU08ly8EkeveaeICEqoNQzIqWzpmoz6Nn571SiAupcV7z 61fQ== X-Gm-Message-State: ANoB5plxPlbXNBOk/XE21SoMej09irm+DObREELapBkOJcJroeFf5lo3 KPN7CJzpEQKFQSmTnypcAbTzOWN9eepvEzjgP6Y= X-Google-Smtp-Source: AA0mqf7nGa6XcWBr/4FuxrcQr5ytkSXnOioCKUd4Z5BDSoQ0DXCuc1HRJBQNgUg1MYGGvxwAefHR/ViwR2qZtvlJMCo= X-Received: by 2002:a67:8c41:0:b0:3af:2625:b2bd with SMTP id o62-20020a678c41000000b003af2625b2bdmr4227651vsd.40.1668473208689; Mon, 14 Nov 2022 16:46:48 -0800 (PST) MIME-Version: 1.0 References: <20221113230521.712693-1-christoph.muellner@vrull.eu> <20221113230521.712693-8-christoph.muellner@vrull.eu> In-Reply-To: <20221113230521.712693-8-christoph.muellner@vrull.eu> From: Kito Cheng Date: Tue, 15 Nov 2022 08:46:37 +0800 Message-ID: Subject: Re: [PATCH 7/7] riscv: Add support for str(n)cmp inline expansion To: Christoph Muellner Cc: gcc-patches@gcc.gnu.org, Kito Cheng , Jim Wilson , Palmer Dabbelt , Andrew Waterman , Philipp Tomsich , Jeff Law , Vineet Gupta Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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: 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. > > 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.