[v2,RFC] vect: Verify that GET_MODE_NUNITS is greater than one for vect_grouped_store_supported
Message ID | 20230327160157.4111747-1-kevinl@rivosinc.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1616862vqo; Mon, 27 Mar 2023 09:02:54 -0700 (PDT) X-Google-Smtp-Source: AKy350YeJOFKr6dXtWZytYTIBiWceZEfmqoq9aL/zIjTgl4vEjlwfA73EQLaGnH+S5QFNnKDxBkG X-Received: by 2002:a17:907:c710:b0:8b1:806b:7dbb with SMTP id ty16-20020a170907c71000b008b1806b7dbbmr13718599ejc.51.1679932973847; Mon, 27 Mar 2023 09:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679932973; cv=none; d=google.com; s=arc-20160816; b=B/jhB1akoBwokDww4vosiLYeeJQc00lnI2JAQGdBqnHhapqCWpB98nUovcY0nuycYT 7JL3uPymDJ3eJQvTM7TaPagGLIiorXNZuQithXQkeEUw/kQZNd6cr7YMpNN1ANDHAf1e VlbaH7rDqgN7SiXq9vNoVusoAIr/vvADRfAgOtylIJNz5JCpn6zRTKwfo6h9gnv7imIL 9txQAlkormQUjtYGWzlvQ0qo7gLGTU2+eGQqCBmQZ+GfXRuYWnTMHPmXBJ8bGax5MMqC WwmcfVoIn5LNzKTb4HM9ViAbJ3HoZvu8tnuikVLm2YdYrT5ko4ev6FHUwm1CbYhVwX8y qfXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=DEFSVVV3l3AyqcjQ9whkfVdma40z6bxWIxX8JQA+Kxo=; b=GSOAxMkB9xj7eIt5YNKtoVr+LEF9y1xkI8qxYAFtUn4hWLU5JmbwyCo71Fbj57OaqL U4Gdb4r/IiW7aUYEbdQr73EjfsmSwu28Z/yPUdyuqV9VrY2PtEzCvbLkB3kOaBHmrrvT WC3mTX4MWOfKJwivGOAy/ZN6wzOlzSFMz4TeVEak0kTYVMPlT6H0Ytjt+2MLfZ2mT728 /g0UZBgYdz6h/ZoquJj921k7NQ4kVds5e7w3SdFFBMwjZ/X0YGvgLpx7r7SE3DaeWztE GTEc2+PEKE6j/DIWfLfzIkgyTf5SPNxZNF714YjNL8FVKCLl3TvT5xGVlsClLRo0yTNc xpXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=O+e4Le4N; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bi22-20020a170906a25600b0093dffa36a23si9082054ejb.502.2023.03.27.09.02.53 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 09:02:53 -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=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=O+e4Le4N; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1000438582AC for <ouuuleilei@gmail.com>; Mon, 27 Mar 2023 16:02:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id 288543858410 for <gcc-patches@gcc.gnu.org>; Mon, 27 Mar 2023 16:02:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 288543858410 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pj1-x1034.google.com with SMTP id h12-20020a17090aea8c00b0023d1311fab3so9363897pjz.1 for <gcc-patches@gcc.gnu.org>; Mon, 27 Mar 2023 09:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1679932931; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=DEFSVVV3l3AyqcjQ9whkfVdma40z6bxWIxX8JQA+Kxo=; b=O+e4Le4NuDGekIz2b3pjVzgBSDGj1OFCmaosF+So1WoN3u7d3P/HOIOVOFooT6hp+U Jr8i1chkpwp6byqrETJSLodygl9KUQtTtWgVZn4mVQZpJPTUk2zaiJ8soR1ztPE0wXsZ Y6QgAe1BtrfzHV5SrdiN76LD8b3YTQYIVOMDsjXraIRMF8Obu+N3YZU76qU7Pg+zymUF C7tgzfwICiDJEP/EIpFZq6Nk2RqPC9iKc6Z8wRt/7z6UDQW0gXXTfpYrzf6c6PT7KVmS vJgTkyXAM1/Rh5f/k1i46oREHK9jLEQKcxKPmtFMXDYOcsIKRjGsYqSGjgtHW7VAkb0h 6urA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679932931; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DEFSVVV3l3AyqcjQ9whkfVdma40z6bxWIxX8JQA+Kxo=; b=nUqq5a+HoLrOwtpMp3gIHG4LPXC/MckmhGi9hvymtnUh1a+E5H9+aE+YArgP9274Ta sOMxUqIZNfFTbD8PNjc8eYlfeEPfMru/gRbOvzKUNw9NHJGD5PIGNhKbBqvjuS9vtuOR UuIPgt8u0cNTi7Xc/+u9XF1MTRlLabMfNcnSBLMzveD7GxWep3xD2YJuotwY6Yb6dBsQ zcAIL22f7yH0DzSx3pxFpqpqnahZ3f2jw//vZb0bzoJgDO1o/xRA9C0vJDpV/uivhuMx A4R+M4Eh/sAcldy6+cwQUZW8Wgtk0m59VkdqCOEZoXrx7HSCy/0f4Mk/zcuuSrtwba8B MrMg== X-Gm-Message-State: AAQBX9evpmurkQCIU6vYlNCvDzHYkCI7q6Hy9tUb08Vu+LYx3rn5xEZP 2qN1/GI6bnebX5Al0rgBx6TrZg1AbnEruoSfzP8= X-Received: by 2002:a17:90b:3850:b0:23b:32e5:9036 with SMTP id nl16-20020a17090b385000b0023b32e59036mr12754425pjb.17.1679932931270; Mon, 27 Mar 2023 09:02:11 -0700 (PDT) Received: from kevinl.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id y1-20020a17090a8b0100b002348d711ebbsm7705135pjn.16.2023.03.27.09.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 09:02:10 -0700 (PDT) From: Kevin Lee <kevinl@rivosinc.com> To: gcc-patches@gcc.gnu.org Cc: collison@rivosinc.com, Kevin Lee <kevinl@rivosinc.com> Subject: [PATCH v2][RFC] vect: Verify that GET_MODE_NUNITS is greater than one for vect_grouped_store_supported Date: Mon, 27 Mar 2023 09:01:57 -0700 Message-Id: <20230327160157.4111747-1-kevinl@rivosinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, 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> 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761537397806041406?= X-GMAIL-MSGID: =?utf-8?q?1761537397806041406?= |
Series |
[v2,RFC] vect: Verify that GET_MODE_NUNITS is greater than one for vect_grouped_store_supported
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Kevin Lee
March 27, 2023, 4:01 p.m. UTC
This patch is a proper fix to the previous patch https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614463.html vect_grouped_store_supported checks if the count is a power of 2, but doesn't check the size of the GET_MODE_NUNITS. This should handle the riscv case where the mode is VNx1DI since the nelt would be {1, 1}. It was tested on RISCV and x86_64-linux-gnu. Would this be correct for the vectors with size smaller than 2? --- gcc/tree-vect-data-refs.cc | 2 ++ 1 file changed, 2 insertions(+)
Comments
On Mon, Mar 27, 2023 at 6:02 PM Kevin Lee <kevinl@rivosinc.com> wrote: > > This patch is a proper fix to the previous patch > https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614463.html > vect_grouped_store_supported checks if the count is a power of 2, but > doesn't check the size of the GET_MODE_NUNITS. > This should handle the riscv case where the mode is VNx1DI since the > nelt would be {1, 1}. > It was tested on RISCV and x86_64-linux-gnu. Would this be correct > for the vectors with size smaller than 2? > > --- > gcc/tree-vect-data-refs.cc | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc > index 8daf7bd7dd3..04ad12f7d04 100644 > --- a/gcc/tree-vect-data-refs.cc > +++ b/gcc/tree-vect-data-refs.cc > @@ -5399,6 +5399,8 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count) > poly_uint64 nelt = GET_MODE_NUNITS (mode); > > /* The encoding has 2 interleaved stepped patterns. */ > + if(!nelt.is_constant() && maybe_lt(nelt, (unsigned int) 2)) > + return false; Indentation is off (or your MUA is broken). I think the nelt.is_constant () check is superfluous but with constant nelt we'd never end up with a grouped store. Note the calls are guarded with && ! known_eq (TYPE_VECTOR_SUBPARTS (vectype), 1U) maybe the better fix is to change those to ! maybe_eq? Richard should know best here. Richard. > vec_perm_builder sel (nelt, 2, 3); > sel.quick_grow (6); > for (i = 0; i < 3; i++) > -- > 2.25.1 >
Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> writes: > On Mon, Mar 27, 2023 at 6:02 PM Kevin Lee <kevinl@rivosinc.com> wrote: >> >> This patch is a proper fix to the previous patch >> https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614463.html >> vect_grouped_store_supported checks if the count is a power of 2, but >> doesn't check the size of the GET_MODE_NUNITS. >> This should handle the riscv case where the mode is VNx1DI since the >> nelt would be {1, 1}. >> It was tested on RISCV and x86_64-linux-gnu. Would this be correct >> for the vectors with size smaller than 2? >> >> --- >> gcc/tree-vect-data-refs.cc | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc >> index 8daf7bd7dd3..04ad12f7d04 100644 >> --- a/gcc/tree-vect-data-refs.cc >> +++ b/gcc/tree-vect-data-refs.cc >> @@ -5399,6 +5399,8 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count) >> poly_uint64 nelt = GET_MODE_NUNITS (mode); >> >> /* The encoding has 2 interleaved stepped patterns. */ >> + if(!nelt.is_constant() && maybe_lt(nelt, (unsigned int) 2)) >> + return false; > > Indentation is off (or your MUA is broken). I think the nelt.is_constant () > check is superfluous but with constant nelt we'd never end up with a > grouped store. > > Note the calls are guarded with > > && ! known_eq (TYPE_VECTOR_SUBPARTS (vectype), 1U) > > maybe the better fix is to change those to ! maybe_eq? I think the point of those checks is that a grouped store of N 1-element vectors is equivalent to a store of N scalars. Nothing needs to happen internally within the vectors. For a grouped store of VNx1 vectors, some permutation would be needed. But it's difficult to generate code for that case, because the minimum size reduces to two scalars while larger sizes need normal interleaves. But I think the better check for location above is: if (!multiple_p (nelt, 2)) return false; which then guards the assert in the later exact_div (nelt, 2). Thanks, Richard
Thank you for the feedback Richard and Richard. > Note the calls are guarded with > > && ! known_eq (TYPE_VECTOR_SUBPARTS (vectype), 1U) Yes, I believe nelt.is_constant() wouldn't be necessary. I didn't realize the call was guarded by this condition. > But I think the better check for location above is: > > if (!multiple_p (nelt, 2)) > return false; > > which then guards the assert in the later exact_div (nelt, 2). I believe this check is better than using maybe_lt because it properly guards exact_div(nelt, 2) and vec_perm_builder sel(nelt, 2, 3). I'll modify the patch accordingly, build, test and submit the patch. Thank you!! Sincerely,
diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc index 8daf7bd7dd3..04ad12f7d04 100644 --- a/gcc/tree-vect-data-refs.cc +++ b/gcc/tree-vect-data-refs.cc @@ -5399,6 +5399,8 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count) poly_uint64 nelt = GET_MODE_NUNITS (mode); /* The encoding has 2 interleaved stepped patterns. */ + if(!nelt.is_constant() && maybe_lt(nelt, (unsigned int) 2)) + return false; vec_perm_builder sel (nelt, 2, 3); sel.quick_grow (6); for (i = 0; i < 3; i++)