From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 2ED3638518A0 for ; Tue, 15 Nov 2022 00:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2ED3638518A0 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dabbelt.com Received: by mail-pl1-x62e.google.com with SMTP id w23so5264904ply.12 for ; Mon, 14 Nov 2022 16:53:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=pIIntF6B3U1ho4WcGk/lnMUu6G0MKyWGmhkWCcpCW8w=; b=QVURWsIqAkD2b4GZp0Ni+gyMORJ6r6bnG436nIR5dIPwbgiE7KKlppbZU8KMzPewyQ FSOxmrOztO/EErrzOs+YvmDxH01rAlfDhm68nYX+kMIpZsJ+eEZfeXrd4YgHlCEZVgLC 2aM/yDEJ5IUtzMLnPPz9FOIt5z7OASNlweece4fhGYVXMySM6aFsjlMYgu4ag9NoIS55 M6f+AUTzSieHWC2TBLOw/wEQEKvpurUHvy2MwBK+CcF8aShsd2m0iZoOvVFFM1OQYw+i i2SPLDxZgSHF0qREIoHanbpoBtXmk0SvHm6bh27HaSZJAtmGjsNVw16htHcev5ILKLkO KHww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pIIntF6B3U1ho4WcGk/lnMUu6G0MKyWGmhkWCcpCW8w=; b=jLp5zu9mHzjEX/ZGh77P/NAVLt3aR8HTnrINrJyEh0xZ0oS3TNRIvQnvVO7yEWRe7O ucoVGM6ZAmJA3FJYMFJjQZtzlJorA1qDlRMUrWQIsLAXU9zaHntgx6hKCQ+Hro9ZtCqa 0Q9tTGAPo5OxwnG2R1gJBWjbOeL9KCRKNwCBthx7x/jJZesImwabl03dtEvo58K418x4 GmaEwvdIbut8MNb1kd79ZawJQMDQVsdyVI2sE0sgD34d5FwpeVRFxb6W6UGjgAxxPV9h +tbs/XkGOyIuXCAGsqkX8UJOzjXEPOCNOQqu07YJEsAd+CjulqhLAyiwO5AQbJRuYwsf fckw== X-Gm-Message-State: ANoB5pkQufVfGGDhtIW0CyV3+vaQBPEdoiq8XM+le/TLRJRd4T4TY3gc jzlT6l2IONh3aFecnWymCSbxUA== X-Google-Smtp-Source: AA0mqf7id/puxLEW2IpDh1DS8lJ6jj5ozrgARHR1qmgclSvn9g8u4VLWJh0Xt8DpZpNzhFC6nWrYqw== X-Received: by 2002:a17:903:2615:b0:188:b5d6:2873 with SMTP id jd21-20020a170903261500b00188b5d62873mr1605642plb.144.1668473601032; Mon, 14 Nov 2022 16:53:21 -0800 (PST) Received: from localhost ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id b6-20020a170902650600b00185480a85f1sm8140153plk.285.2022.11.14.16.53.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 16:53:20 -0800 (PST) Date: Mon, 14 Nov 2022 16:53:20 -0800 (PST) X-Google-Original-Date: Mon, 14 Nov 2022 16:53:16 PST (-0800) Subject: Re: [PATCH 7/7] riscv: Add support for str(n)cmp inline expansion In-Reply-To: CC: christoph.muellner@vrull.eu, gcc-patches@gcc.gnu.org, kito.cheng@sifive.com, Jim Wilson , Andrew Waterman , philipp.tomsich@vrull.eu, jeffreyalaw@gmail.com, Vineet Gupta From: Palmer Dabbelt To: Kito Cheng Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,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 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. >> 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.