Message ID | 9a28abc7-b305-6ac3-19b7-4426b6c76b43@gmail.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp1630877vqi; Fri, 18 Aug 2023 12:37:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhT7ECnNLpSpcfJZGaPLiTqqNN9CBrhsTWstJ5Pqesdn52jp9ua4wKrJusOLHztXmht2pQ X-Received: by 2002:a17:906:257:b0:993:f349:c98c with SMTP id 23-20020a170906025700b00993f349c98cmr122131ejl.4.1692387476057; Fri, 18 Aug 2023 12:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692387476; cv=none; d=google.com; s=arc-20160816; b=ALt2bGUr0GDCgZrrsxepevvWmCXityKQedlaOkGNHRUA8I74vl6cM1/sifYWLbdSz9 eZvwK2SRVszEW4pZzgNOym+izacvCZikTl6bYQtQXwx3xgvbd3ELrmGKqMiIXVuCqoer D+3s1A69/Wn+ViupSdea4mUmOAW9PKXe0X1jKh9NGAMZ+80iGpdPeOxyIqoluusoWpnt d/f6OfeQE+ZXJJ9qfCcVEjhlP7APp+7LCy3fVjuSXEQVGLsTzIM5N45KyTXDOGilmHnY c/byXWOOgdwI1NDb84qzKs+JQLgp1YfcuyU/G2KDWi9oG4WJYGw9Z1O+SHalYmfAqnDz u/bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:to:content-language:cc:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=LwWkCJI/i5SX4PrykjPM2tpUPGmU7Xuji1/CrRvPSVg=; fh=ndvsZwFmZ+tyX7/x1KzctP6d5wHm+PTZEsDUSis59ys=; b=veizxgaLz+gs0vWrGPLDLwdJ5sWgK3PxKZDI0Re/EHV766y6w30t3553UVJTuFQFTd oxcjH3SrL+x18E/j/DFC4WKjGX7w2K8ovXGVbQL25O/jm9l2bgOTZjD9i4PO/wTaNG8m 9Y4JnIMP4L0EX0PKJTaVoCyOlW2qvF/eBMEGKupKpsjQD/L74NRQ7CH76yovcWTXJsdB 8AtUzsrRuvgdWRso/5mVlqXwipgw+TQfgexG6aJjBvq69oJlTt+NFc12loEswSaEDG4R buurBbyt1GEfDticm3T9yWapeeO4ohoIFy0qcWpGreTn9Lawb+gPViSPuyNl5lu1BRdu WIcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yMOlSay2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id au28-20020a170907093c00b00991f834e0b3si1609495ejc.194.2023.08.18.12.37.55 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 12:37:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yMOlSay2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AD246386D63E for <ouuuleilei@gmail.com>; Fri, 18 Aug 2023 19:37:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD246386D63E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692387474; bh=LwWkCJI/i5SX4PrykjPM2tpUPGmU7Xuji1/CrRvPSVg=; h=Date:Cc:To:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=yMOlSay2fqhk5XvvfCnwjvYgCy/FYBIFE5HHQ16wldGq//iZP5RpwRGh1iMgMbdLc sHZvMC15rChfVAeJkW73J6jx3dzhKTujW+WnM52GmIVX7YAFhOnaOlLDu6DOfJwLgH FVrT+Zno12K5bs70aw2tGWNIHyF2WqjJhPnUChE8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 0FF35386480A for <gcc-patches@gcc.gnu.org>; Fri, 18 Aug 2023 19:37:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FF35386480A Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-99c0290f0a8so153288666b.1 for <gcc-patches@gcc.gnu.org>; Fri, 18 Aug 2023 12:37:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692387428; x=1692992228; h=content-transfer-encoding:subject:from:to:content-language:cc :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=LwWkCJI/i5SX4PrykjPM2tpUPGmU7Xuji1/CrRvPSVg=; b=LpIi3ENLgM4rnD+HyO2HK55EAcwoK0hOlwdiTtYOvBWjLAJxcZBUyKARCSu0z92pnh OMniXmJsZVxItczglT0FSkKnhXbZTxNCSQh8m2hC+G4eJqeAprQu3QMIrAYe8IjgF1SC aloBmhrR2W91/BqvwOEqUIeu6sUGGTzsedWIPxWavXnjPBxL0OCvVbaUdHn1VNnjuYpX utciPDwwzPliLFdJ5RvC49NDqYkn8lEIyd/KqTaOlEPwOovjxuCeSRxqsfjQqyxKn802 HLFCzgtJ+VvDzjoqnUxYI0nMpXsmnh6ZRapdnx+iNBaF7GrZgUaiY1G9o1MyVCS1J1sL NZ8Q== X-Gm-Message-State: AOJu0YxzjyXH5J8RyeRnEryoBNtEaayt5Qkaz6DcxkEF9O4gB9Cssc24 O4znoABzUZXF+r7aYt2lJiZLF/8ZnVQ= X-Received: by 2002:a17:906:10d2:b0:99b:b3a1:437b with SMTP id v18-20020a17090610d200b0099bb3a1437bmr120944ejv.40.1692387428268; Fri, 18 Aug 2023 12:37:08 -0700 (PDT) Received: from [192.168.1.24] (ip-046-005-130-086.um12.pools.vodafone-ip.de. [46.5.130.86]) by smtp.gmail.com with ESMTPSA id e22-20020a170906249600b0099cc1ffd8f5sm1541106ejb.53.2023.08.18.12.37.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Aug 2023 12:37:07 -0700 (PDT) Message-ID: <9a28abc7-b305-6ac3-19b7-4426b6c76b43@gmail.com> Date: Fri, 18 Aug 2023 21:37:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: rdapp.gcc@gmail.com Content-Language: en-US To: gcc-patches <gcc-patches@gcc.gnu.org>, palmer <palmer@dabbelt.com>, Kito Cheng <kito.cheng@gmail.com>, jeffreyalaw <jeffreyalaw@gmail.com>, "juzhe.zhong@rivai.ai" <juzhe.zhong@rivai.ai> Subject: [PATCH] RISC-V: Allow immediates 17-31 for vector shift. Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Robin Dapp via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Robin Dapp <rdapp.gcc@gmail.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774596890384443798 X-GMAIL-MSGID: 1774596890384443798 |
Series |
RISC-V: Allow immediates 17-31 for vector shift.
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Robin Dapp
Aug. 18, 2023, 7:37 p.m. UTC
Hi, this patch adds a missing constraint check in order to be able to print (and not ICE) vector immediates 17-31 for vector shifts. Regards Robin gcc/ChangeLog: * config/riscv/riscv.cc (riscv_print_operand): gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/binop/shift-immediate.c: New test. --- gcc/config/riscv/riscv.cc | 3 ++- .../riscv/rvv/autovec/binop/shift-immediate.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c
Comments
On Fri, 18 Aug 2023 12:37:06 PDT (-0700), rdapp.gcc@gmail.com wrote: > Hi, > > this patch adds a missing constraint check in order to be able to > print (and not ICE) vector immediates 17-31 for vector shifts. > > Regards > Robin > > gcc/ChangeLog: > > * config/riscv/riscv.cc (riscv_print_operand): > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/rvv/autovec/binop/shift-immediate.c: New test. > --- > gcc/config/riscv/riscv.cc | 3 ++- > .../riscv/rvv/autovec/binop/shift-immediate.c | 16 ++++++++++++++++ > 2 files changed, 18 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c > > diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc > index 49062bef9fc..0f60ffe5f60 100644 > --- a/gcc/config/riscv/riscv.cc > +++ b/gcc/config/riscv/riscv.cc > @@ -4954,7 +4954,8 @@ riscv_print_operand (FILE *file, rtx op, int letter) Looks like the comment at the top of riscv_print_operand() is way out of date. Maybe we should just toss it? > else if (satisfies_constraint_Wc0 (op)) > asm_fprintf (file, "0"); > else if (satisfies_constraint_vi (op) > - || satisfies_constraint_vj (op)) > + || satisfies_constraint_vj (op) > + || satisfies_constraint_vk (op)) > asm_fprintf (file, "%wd", INTVAL (elt)); > else > output_operand_lossage ("invalid vector constant"); > diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c > new file mode 100644 > index 00000000000..a2e1c33f4fa > --- /dev/null > +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c > @@ -0,0 +1,16 @@ > +/* { dg-do compile } */ > +/* { dg-additional-options "-std=c99 -march=rv32gcv -mabi=ilp32d -O2 --param=riscv-autovec-preference=scalable" } */ > + > +#define uint8_t unsigned char > + > +void foo1 (uint8_t *a) > +{ > + uint8_t b = a[0]; > + int val = 0; > + > + for (int i = 0; i < 4; i++) > + { > + a[i] = (val & 1) ? (-val) >> 17 : val; > + val += b; > + } > +} Unless I'm missing something it looks like we're missing at least Wc1 as well, and maybe a few others? Either way Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> Thanks!
On 8/18/23 13:56, Palmer Dabbelt wrote: > On Fri, 18 Aug 2023 12:37:06 PDT (-0700), rdapp.gcc@gmail.com wrote: >> Hi, >> >> this patch adds a missing constraint check in order to be able to >> print (and not ICE) vector immediates 17-31 for vector shifts. >> >> Regards >> Robin >> >> gcc/ChangeLog: >> >> * config/riscv/riscv.cc (riscv_print_operand): >> >> gcc/testsuite/ChangeLog: >> >> * gcc.target/riscv/rvv/autovec/binop/shift-immediate.c: New test. >> --- >> gcc/config/riscv/riscv.cc | 3 ++- >> .../riscv/rvv/autovec/binop/shift-immediate.c | 16 ++++++++++++++++ >> 2 files changed, 18 insertions(+), 1 deletion(-) >> create mode 100644 >> gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c >> >> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc >> index 49062bef9fc..0f60ffe5f60 100644 >> --- a/gcc/config/riscv/riscv.cc >> +++ b/gcc/config/riscv/riscv.cc >> @@ -4954,7 +4954,8 @@ riscv_print_operand (FILE *file, rtx op, int >> letter) > > Looks like the comment at the top of riscv_print_operand() is way out of > date. Maybe we should just toss it? I think it's been out of date on every port I've ever worked on! Folks start with good intentions, but nobody seems to keep this up-to-date. So +1 to removing it if someone wants to. I'll even pre-approve such a patch. I'll also pre-approve a patch which brings it up-to-date if that's the direction we want to go. jeff
On 8/18/23 13:37, Robin Dapp wrote: > Hi, > > this patch adds a missing constraint check in order to be able to > print (and not ICE) vector immediates 17-31 for vector shifts. > > Regards > Robin > > gcc/ChangeLog: > > * config/riscv/riscv.cc (riscv_print_operand): > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/rvv/autovec/binop/shift-immediate.c: New test. OK jeff
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 49062bef9fc..0f60ffe5f60 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -4954,7 +4954,8 @@ riscv_print_operand (FILE *file, rtx op, int letter) else if (satisfies_constraint_Wc0 (op)) asm_fprintf (file, "0"); else if (satisfies_constraint_vi (op) - || satisfies_constraint_vj (op)) + || satisfies_constraint_vj (op) + || satisfies_constraint_vk (op)) asm_fprintf (file, "%wd", INTVAL (elt)); else output_operand_lossage ("invalid vector constant"); diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c new file mode 100644 index 00000000000..a2e1c33f4fa --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c99 -march=rv32gcv -mabi=ilp32d -O2 --param=riscv-autovec-preference=scalable" } */ + +#define uint8_t unsigned char + +void foo1 (uint8_t *a) +{ + uint8_t b = a[0]; + int val = 0; + + for (int i = 0; i < 4; i++) + { + a[i] = (val & 1) ? (-val) >> 17 : val; + val += b; + } +}