From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 4AE113948808 for ; Wed, 16 Nov 2022 00:16:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4AE113948808 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-lj1-x232.google.com with SMTP id l8so19728253ljh.13 for ; Tue, 15 Nov 2022 16:16:08 -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=I8bROBQFZUKQFX/5HI5+oCpZJuiLriHD0IrAqy91amQ=; b=lduAcCnn5n54x/Y9rE6LHb53zUbHEGboZ7rPgxraX5TWaX+HI9o/vhiM+3WAU3X+xf 3YkMNRZZEY3bGONjoPWAch6h0ibMphx3O3uqKr6Mfv0V7kLfrEDcT1Rbghno/njy0t3D 7SkUpoxnsfVti1jLukaxLj1vpql0vCP87QTikfbaHcmop8D+r6OEnWsfgcEjGxxZsrlE ZwtU1L4YffRKey/xZtoRM8RvySmJbO9i2D2jLKYXkrJQnPtUNhB07EBx+06CkPOT1G9V LwfE2AlqHfukZIg3rklK4+ZWhXEdDIdN74OqQceHPLjAY9bMzDtZnJrvxYLBlIMSEtxP Zxrg== 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=I8bROBQFZUKQFX/5HI5+oCpZJuiLriHD0IrAqy91amQ=; b=QpgakoTv9ulG3sl4Aw6wTTk2WUi3nQjKRooNyGorlIVwoCHjMS/tFxd5kzSQKgd7o+ H/VzBgbDkrtwRP/Usxwqhw1XHP83gpXUCzuY+gIILDqN1PEioSyY4TXSvf+kx1AIf+/J peDDornWlAl977qI0UQOX/EXtbBWywYjn7yTXFAMtFeXX7mc7LUU2bVYv0pz5jsJOEZN M9UaA8ojGowmTzIfq+tHoUokjcC5dlBP4MxDX1/H1HLlquvbbT0rMHOaSWvYemo87+co WcYn645yQya6DUXlavEEROzIbtSU4QR0dmE1QCoLwdqzwH/kBMgD2y2d/bGzQFR3w+09 B/zw== X-Gm-Message-State: ANoB5pmRhIRf0clblFnPJgqVvTSHM4KcedE0ILS+PJ6J59S5cmh7fxVb OAd+yx8qSAL/ioWVacXFzJEgDFR6+x2wgO8e5PcXkg== X-Google-Smtp-Source: AA0mqf4X5+mmw6u9ZxqKGdws4XKvR6VfGXNXJ3ud7930ViYhiOrC0kxX/dPA4YXKr/vx0dGvIJsKgAr4niiDsI9wqoc= X-Received: by 2002:a2e:9b8d:0:b0:276:ffd1:d7c8 with SMTP id z13-20020a2e9b8d000000b00276ffd1d7c8mr6415966lji.176.1668557766618; Tue, 15 Nov 2022 16:16:06 -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: Philipp Tomsich Date: Wed, 16 Nov 2022 01:15:55 +0100 Message-ID: Subject: Re: [PATCH 7/7] riscv: Add support for str(n)cmp inline expansion To: Kito Cheng Cc: Christoph Muellner , gcc-patches@gcc.gnu.org, Kito Cheng , Jim Wilson , Palmer Dabbelt , Andrew Waterman , Jeff Law , Vineet Gupta Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: On Tue, 15 Nov 2022 at 01:46, 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. For the basic option (-m[no-]inline-str[n]cmp), I would punt to -fno-builtin-str[n]cmp. The limit-one sounds more like a --param? > And add some option like this: > -minline-str[n]cmp=[bitmanip|vector|auto] in future, If we want to follow the lead of others, then x86 has a -mstringop-strategy=alg > 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.