From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by sourceware.org (Postfix) with ESMTPS id 8FB4D3887F7C for ; Tue, 15 Nov 2022 22:23:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8FB4D3887F7C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-io1-xd30.google.com with SMTP id 63so11848521iov.8 for ; Tue, 15 Nov 2022 14:23:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; 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=SbkLyQNZ6fQrCj60xwuZmkO/m942eNxzs5N9hAQ7QPE=; b=ZsrVeu1u10Nd2KyJmZBNWoiIYpYQl56WCI8ambI7UlqE1WBdPCQKH9s42RruAXhvzt VIBUohPgiCFd7WLI669N20ZqJu0gbGYws5rlZHduK3vajIH0Xg7vJGCJMuxS20yAG563 yk/VrzD1TyXKLRk1OW7uGeoNtGsk4qCljHdZ5zTGQnBnSr22dcPQz5fMgwdmmb87R7Vm DtYS6ytRYbCiEL15gW+Aa+0lUI6WXC2eebA9v8SJKgxir1QGBLFn2UuIW3tQN3dt5JtD FhGQQUkKZvEgI8C+YI/0g57hjY/5z/zbGyY0AcE1Qn7FygudLOqKH7oEoqEIMXFQhnzC AEjg== 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=SbkLyQNZ6fQrCj60xwuZmkO/m942eNxzs5N9hAQ7QPE=; b=5Xnf0DLgfTNl9/JQe2YvyAzoF7qqj+Mlt/fPuX4xMXCnMCBUhPuwVZyx+KHAz5U/8a 6Wc1ucFXOBpa02ydDhPZ0Wl2o0llPGpx7WsRELuYlK1TBMTbRe0323H58FMObcwvB9rp po+bE6PljzdQvNrEtgeFZqgov2S+uMPPBls/8sI1q/rrRIcO3OX6wRrAKTlBjGRh5Bf3 Z/uyQfeIoqolAhh+97zVvx+9XPh9fIKGQMjkLolGoSbG1Hm7QrR/zk0jygedWP5yidwu bxf7OuH4r3lIsNsrcKkoJFotWN+b9k6XsVuh3sUZcYDOSHomQj1uJuLKd87lz6OdEkgk OdPQ== X-Gm-Message-State: ANoB5pla4q8ZCltTVy/QHoc3FYcXfyczpaL8ycQ1l+eJi1YRAiWwvFFl qcPaTYo76tg0VpUkN8HLJv2VHBazETIz+D9KHh1pMw== X-Google-Smtp-Source: AA0mqf7yXo/t7gWd/chJfYAiSzkt2R1NNcZyqc1lMAACiZV2En5kXsoWUJ9kUMcctZvqhpR+XQZR3dBEWFm6WKRkncc= X-Received: by 2002:a02:cc02:0:b0:365:cd53:9fbb with SMTP id n2-20020a02cc02000000b00365cd539fbbmr8934611jap.220.1668550989767; Tue, 15 Nov 2022 14:23:09 -0800 (PST) MIME-Version: 1.0 References: <20221113230521.712693-1-christoph.muellner@vrull.eu> <20221113230521.712693-8-christoph.muellner@vrull.eu> In-Reply-To: From: =?UTF-8?Q?Christoph_M=C3=BCllner?= Date: Tue, 15 Nov 2022 23:22:58 +0100 Message-ID: Subject: Re: [PATCH 7/7] riscv: Add support for str(n)cmp inline expansion To: Kito Cheng Cc: gcc-patches@gcc.gnu.org, Kito Cheng , Jim Wilson , Palmer Dabbelt , Andrew Waterman , Philipp Tomsich , Jeff Law , Vineet Gupta Content-Type: multipart/alternative; boundary="00000000000008fd4a05ed89cd68" X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --00000000000008fd4a05ed89cd68 Content-Type: text/plain; charset="UTF-8" On Tue, Nov 15, 2022 at 1:46 AM 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. > Ok, I don't mind (in fact, I thought about this as well). The reason why it is how it is: I took inspiration from the rs6000 backend. > 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. > --00000000000008fd4a05ed89cd68--