From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc2e.google.com (mail-oo1-xc2e.google.com [IPv6:2607:f8b0:4864:20::c2e]) by sourceware.org (Postfix) with ESMTPS id 0E2FE3858C31 for ; Fri, 1 Dec 2023 00:49:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E2FE3858C31 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0E2FE3858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c2e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701391780; cv=none; b=JeGNwuUpbB5qyzN7NkrDPCBtITg/VxaA+yMrVYofx+gZb5LU+dGbZ9GuUaMVnX91x/xmAPlNzJXnIQa0o5eBvmetQagbThqydF+K4JhZjg5M/8WAWy+CV8msU2ZWvKe4on+CdtCcvvBQi+JHjojojIlKEXr+hcX5fqYKUcttSqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701391780; c=relaxed/simple; bh=JxW4f6n1M0pNn2RzTPOMfMtcjiuZVMAOMJiEPtKBsLw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=NgMsFtW6Igwe9ST613FiBkYec7TERNzk78BoPlbMotsulX8Ww9W+RCmhNsvJPlUo9gFgXceDHzQNd6j+dcKw9i0IpSPaUgyEKpceLdvKE1feNJwGA5251gIYYlwDfJ2+r40wp7E46gYeHC+VB5SEL53d/pVubnHKBco2ddNU+gk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-58ceab7daddso801575eaf.3 for ; Thu, 30 Nov 2023 16:49:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701391778; x=1701996578; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bgs9zu+f6yAN37x81JwoKT/yKIbbTERmTF393pkBZCs=; b=f455icffoWr5Uw1VR1wV0EdvYCsxrCcLcXDCNdl50jLQxjNw5aaLafJNQxLN7jgwrD l90SW7j12NArBY7qkO5HeNxZn3mNmyOUcc5J1MuvIHMwMy0HlxwOyKL8HizfjDaj8rbe DFAi+Sk1wiNuo1ur2tF+gSTPUVJPkMPjcK2Q7L33OXfxvYhcfCG+8bbEwqGhb9ZWmM1I NR16GO1FVyOlVDMPwG9cvlUyv2L09t+9F8bW2uwOuqXOhbRIGcNrBv1rE0lY/dpRfAeK fq/vdqJB26BQOaenNXhMRs2oLXwvBU3Qyo98hv9qRsPcUSIZpOkXIu/QRPG7fmQfXfUE NZ8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701391778; x=1701996578; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bgs9zu+f6yAN37x81JwoKT/yKIbbTERmTF393pkBZCs=; b=Ou0sCX57Pjgvl9+3KitfVmOde845C/srPia1RM1pn7O8J4xzTjmqL+9Lxj6ltqOAaP H4XaE/GVlcWMoyycSlh/1g94Q1yfl5s2R9pY+Y0OQLL0a6zxnHPqIJKNA7jSdATIOB7J WsKILyR9XBusY3D5YtvHJvu45ITJkFr1xrXk7JTI0xDPvtIbpHWnGwTuKiX04rhurulT Hmeqz2wbnET4ddtwbvKDOtFfVUfuOLgjsmXRYEvIRuW3ejfcJvMI7KpdEqUq6uVWnL8l 4u6935EB4ToC7bhUowgtlwzNgcvo9tcN4BnQhmDA8U+WkaTRBF4EX2vjTHlHpWBhIvUj vPEg== X-Gm-Message-State: AOJu0Yzcy2B/ogZcBtlWYkIz404zeYyR6DFnEF9lsOmAmZYXxjoBiuiX iS81VEhxiIqz5TjUXDbxrS0= X-Google-Smtp-Source: AGHT+IFqjzN5tmescWlPPMwZZgRiFrg8Wov398NYA0oQ3cdSRdHthJGwLvQne36bqxWPExohiw0+wg== X-Received: by 2002:a05:6358:70a:b0:16d:bc51:7601 with SMTP id e10-20020a056358070a00b0016dbc517601mr15660491rwj.9.1701391778218; Thu, 30 Nov 2023 16:49:38 -0800 (PST) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id k24-20020a63f018000000b0057825bd3448sm1873948pgh.51.2023.11.30.16.49.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Nov 2023 16:49:37 -0800 (PST) Message-ID: <575c24fe-ad04-41c1-82c9-c6f48b51ec9c@gmail.com> Date: Thu, 30 Nov 2023 17:49:31 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] RISC-V: Vectorized str(n)cmp and strlen. Content-Language: en-US To: Robin Dapp , gcc-patches , palmer , Kito Cheng , "juzhe.zhong@rivai.ai" References: <2cf2fa3f-541b-4c39-8689-161c7a047f7a@gmail.com> From: Jeff Law In-Reply-To: <2cf2fa3f-541b-4c39-8689-161c7a047f7a@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 11/30/23 15:22, Robin Dapp wrote: > Hi, > > this adds vectorized implementations of strcmp and strncmp as well as > strlen. strlen falls back to the previously implemented rawmemchr. > Also, it fixes a rawmemchr bug causing a SPEC2017 execution failure: > We would only ever increment the source address by 1 regardless of > the input type. > > The patch also changes the stringop-strategy handling slightly: > auto is now an aggregate (including vector and scalar, > possibly more in the future) and expansion functions try all > matching strategies in their preferred order. > > As before, str* expansion is guarded by -minline-str* and not active > by default. This might change in the future as I would rather have > those on by default. As of now, though, there is still a latent bug: > > With -minline-strlen and -minline-strcmp we have several execution > failures in gcc.c-torture/execute/builtins/. From my initial analysis > it looks like we don't insert a vsetvl at the right spot (which would > be right after a setjmp in those cases). This leaves the initial > vle8ff without a proper vtype or vl causing a SIGILL. > Still, I figured I'd rather post the patch as-is so the bug can be > reproduced upstream. > > Regards > Robin > > gcc/ChangeLog: > > PR target/112109 > > * config/riscv/riscv-opts.h (enum riscv_stringop_strategy_enum): > Rename. > (enum stringop_strategy_enum): To this. > * config/riscv/riscv-protos.h (expand_rawmemchr): Add strlen > param. > (expand_strcmp): Define. > * config/riscv/riscv-string.cc (riscv_expand_strcmp): Add > vector version. > (riscv_expand_strlen): Ditto. > (riscv_expand_block_move_scalar): Handle existing scalar expansion. > (riscv_expand_block_move): Expand to either vector or scalar > version. > (expand_block_move): Add stringop strategy. > (expand_rawmemchr): Handle strlen and fix increment bug. > (expand_strcmp): New expander. > * config/riscv/riscv.md: Add vector. > * config/riscv/riscv.opt: Ditto. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/rvv/autovec/builtin/strcmp-run.c: New test. > * gcc.target/riscv/rvv/autovec/builtin/strcmp.c: New test. > * gcc.target/riscv/rvv/autovec/builtin/strlen-run.c: New test. > * gcc.target/riscv/rvv/autovec/builtin/strlen.c: New test. Do you want to extract the rawmemchr fix and push it forward independently? Or do we think the vsetvl issue will be resolved quickly enough that extraction of that fix would just be "make work"? Jeff