From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AKy350bFqHmuPtrpu6IQPnPuaJ8KpRtyCMQHl5JzJiallFA3/SnEBmaEvQlNxnrrffxFhGsYMpl3JA== 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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)) -- 2.25.1