From patchwork Thu Mar 23 05:11:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Lee X-Patchwork-Id: 73804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2727315wrt; Wed, 22 Mar 2023 22:12:31 -0700 (PDT) X-Google-Smtp-Source: AK7set+NmJg1N16/MWxMx3SSTrJMRTCebWZ8o96g6+ttNaUMzrUzCX9YrL+RTeh37eD7FkLZNafA X-Received: by 2002:a17:906:b309:b0:92b:6b6d:2daf with SMTP id n9-20020a170906b30900b0092b6b6d2dafmr8964243ejz.77.1679548351710; Wed, 22 Mar 2023 22:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679548351; cv=none; d=google.com; s=arc-20160816; b=KvCJieduGdPTOy44PhoF+BGF9NwT+9ze8JjyCQzACleIWVNnonBsTAl2cxq9KY7a/H dsEMGFWo7Q0x+yi8oa5uEkTI1yqeLed4IkdsuP0czzUdeTnYCBx398b2JzFfh8Vvcl6K dVVThk3ozN1lLa6bVh0rpmkZxD4sBlzdpnA1U5Ve853zGeyAAz3smcrwlC9i4E75tg0/ Cf2h/p2yEXfT/iG1i3fSBZ/lGYpIGUQ7EhXZKtr4nV5de/U9wEiy+w0oTfrfeMtBXbiw KI9SPfidFEUGsdTepBYb02r9ndFhoRAel8ypdeQC18yO1EPFWI4GdSDV8u1A8alVCLdf Ef5A== 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=lPvJhnEXyHe6Zeg0hQfkOSF3HOJMw+M3VqF39Uu7E1s=; b=ZfnjDz2m1yqKJ6bGGg02z5iRY882RmlyLsW+s3Q2ViXmVo9t6i4fjLAP+tAriQDUOU MAlgtSTLPTRRpOS+O1GYs3OIHudkPM23uvfhk/uUeEEXmqn/jkGccADZQZPDNHvcqLxp Z6gHRYEIdC1W6T0j/xLcsgvODcoNtdRDNOYTIqruAf4nTIOMNK6thu1XJTYVbl+ZFLXR B58b+fABqltwDLbtHolGBcPVKvpErOd/1g9YFG79y69O0KO53AcLXiN9dCC0cTBzPLj1 A2ken7XNwM5b4Yz6GOfR+z4wMg7UvJ290jNfxk2zXMjHIc5ErRGyaHwdVS9xTQ6bDk8s LdmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=lxVZX8am; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i1-20020a056402054100b004acc613462fsi16447154edx.525.2023.03.22.22.12.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 22:12:31 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=lxVZX8am; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 DC58E385041A for ; Thu, 23 Mar 2023 05:12:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id B5672385843D for ; Thu, 23 Mar 2023 05:11:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5672385843D 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-x102e.google.com with SMTP id gp15-20020a17090adf0f00b0023d1bbd9f9eso878652pjb.0 for ; Wed, 22 Mar 2023 22:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1679548318; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lPvJhnEXyHe6Zeg0hQfkOSF3HOJMw+M3VqF39Uu7E1s=; b=lxVZX8amQzn+1VV5O0M4D3EaI5KtgznDFDWoCicSWCAmXh8DLOMoJI+pb0Fd3KAsTW bOVkfCiAH0THABHc0Q63tfNBSK3btxDTVTZ+1KFrWe1lyHQR6vR/LDgBUl0Wm3mwTYg2 XxBYSpaQqLjEYC/3HrFxkrG4IYuYAVhU8JvjQx+ml4VtKp/YgtPebewDPs5r0o4ubufn kTcr/sBDzU8N6shzSTXfySlof9UUplFhaunlQPACZuF5LX+6n2u+Zjk/SO+zgynD7yr1 tgr7mgTeVpKCPsawlce1YJ62wXzVnivdVZgLtR5+gAj7SBCe3RMXyNl8kG7ksmeIutax DYmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679548318; 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=lPvJhnEXyHe6Zeg0hQfkOSF3HOJMw+M3VqF39Uu7E1s=; b=cM5r59maprTf7G+d/KW3/CQiStifb+n/ZmiNnm5EssvVjqfN+ct8sOOFJOkk3R3Ln5 6YTAeiDjUJzbom9tUo4oPrQfGPxXvN+6QLorWV1SqboKApOtrya+t0u27L1LE8iUtXUU dx1OqJPgJA5nWAjL+WbYDR5FfKdkUIQUKCTlXRQVqszj0/DCf6GoDed49NMdwppHVqOi i9aqW++2OknAbOuy9zgpCPlfEcm0Q49q7eU6Ud8aZ0qpj6whpLA+vSqQlzbPVEmBo8kR S3wZl8YgxEIWW9KFxRyDnK2pNo6z1kDiAZARQlGLRf518AtQ95xMLU3P+8Stlf3wJUlD fPZQ== X-Gm-Message-State: AAQBX9d5BkbwEWtdzYIIWjhDohrPkhyfC2gp2dhXDZCzbjVqg4ZufZXh hrMh3w4JFHSYjGW3M1cw3cOD9AKI/xd69vtT4e4= X-Received: by 2002:a17:90a:bd01:b0:236:a1f9:9a8a with SMTP id y1-20020a17090abd0100b00236a1f99a8amr4189270pjr.8.1679548318195; Wed, 22 Mar 2023 22:11:58 -0700 (PDT) Received: from kevinl.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e35-20020a17090a6fa600b0023493354f37sm404428pjk.26.2023.03.22.22.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 22:11:57 -0700 (PDT) From: Kevin Lee To: gcc-patches@gcc.gnu.org Cc: gnu-toolchain@rivosinc.com, Kevin Lee Subject: [RFC][Patch] vect: verify that nelt is greater than one Date: Wed, 22 Mar 2023 22:11:51 -0700 Message-Id: <20230323051151.2982138-1-kevinl@rivosinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761134092385036741?= X-GMAIL-MSGID: =?utf-8?q?1761134092385036741?= This is a patch related to https://gcc.gnu.org/pipermail/gcc-patches/2023-March/613977.html, aiming for gcc14. Since the RISC-V target has vector modes (e.g. VNx1DImode) with nelt smaller than 2, npat has to match with the nelt to create proper vec_perm_indices. I tested on x86_64-linux-gnu and didn't cause more failures, but wasn't sure if total_elem would be used in the rest of the function. Should there be additional changes in the vect_grouped_store_supported? Thank you! gcc/ChangeLog: Kevin Lee * tree-vect-data-refs.cc (vect_grouped_store_supported): Check if the nelt is greater than one. --- gcc/tree-vect-data-refs.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc index 8daf7bd7dd3..9c09cc973d0 100644 --- a/gcc/tree-vect-data-refs.cc +++ b/gcc/tree-vect-data-refs.cc @@ -5399,17 +5399,20 @@ 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. */ - vec_perm_builder sel (nelt, 2, 3); - sel.quick_grow (6); + + unsigned int npat = known_gt(nelt, (unsigned int) 1) ? 2 : 1; + unsigned int total_elem = npat * 3; + vec_perm_builder sel (nelt, npat, 3); + sel.quick_grow (total_elem); for (i = 0; i < 3; i++) { - sel[i * 2] = i; - sel[i * 2 + 1] = i + nelt; + sel[i * npat] = i; + sel[i * npat + 1] = i + nelt; } vec_perm_indices indices (sel, 2, nelt); if (can_vec_perm_const_p (mode, mode, indices)) { - for (i = 0; i < 6; i++) + for (i = 0; i < total_elem; i++) sel[i] += exact_div (nelt, 2); indices.new_vector (sel, 2, nelt); if (can_vec_perm_const_p (mode, mode, indices))