From patchwork Mon Apr 17 18:36:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Collison X-Patchwork-Id: 84404 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2329655vqo; Mon, 17 Apr 2023 11:42:38 -0700 (PDT) X-Google-Smtp-Source: AKy350a3lWrw1qZ00R9YuysW0gHpeMGFuIq4dU6zcS5Dnh6ve5o2PPgwtE913UsA4W4jNS807eUD X-Received: by 2002:a17:906:ce2e:b0:94b:869b:267 with SMTP id sd14-20020a170906ce2e00b0094b869b0267mr8572950ejb.28.1681756958572; Mon, 17 Apr 2023 11:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681756958; cv=none; d=google.com; s=arc-20160816; b=D4Eq2gE2oJSqY8YzmwTRepyKbu+t1JXLdEwtKBS5SIdmXzKyS32nm7HCJQhR6h1gS5 l/ui9jx7aqM5nWfRBNyTF34ub0B04yD5qnXUMytiHvB+16XXSZHtBNapQZgg3I6zvjRg 0DC8Ufg0xb9FIlAnuN8EPC2v3oGeb1+TVZZfU2VaH0uHaazk4htlZ0HmFCf29rhVGSKA uw6Hp1hinN9LWuIkkXgVPQufRhanwJEENNI8ljsaGwGE0BNu+YqZANsHVITFM+9OZeBf aD7jYX3hd7XkJ5xAz5uYUBw/UCLSe3cyQf+Tui46VC2IFiXzprieXJNFLtI0ctQGupSM xSrA== 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:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:dmarc-filter:delivered-to; bh=kk2WGDXFeHiGM8032nSpYvQDeqnXR2eC4cAWeTz8dgE=; b=duTJmX4cgiJ279TGAQKw1E4yebgqm0hP4Easpca9LznU6cVGca+Dg6CmzOSwYUyGg3 m1V9MYVJUruzGQHN+vol5SiFKBvcE/5uRKJZ647/IXUGLq7+WmyArIheXeyflOkozHxx m4uOMrJDgbD3EuydOvuxqPvyn8vY8qYYTytgedSzAMdd0SrEQ8qWAmpCgMZ7gnMKLQaz I9N919iBHrHRt4LMtSmWPcTIej34pSlmpqQJax5fqTNUEm0Cc2rcF6NRormD4n4aTQvA vjgT/bTIx3TKJuOMGIbAmCVwG26iKKxmKM+/p8xLzWSkw3i54jggA5r1jDVHu34jWtNG c6qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=T0yPD3+t; 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 fe6-20020a1709072a4600b0094f05fee9desi5697413ejc.101.2023.04.17.11.42.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 11:42:38 -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.20221208.gappssmtp.com header.s=20221208 header.b=T0yPD3+t; 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 A0679382A2DB for ; Mon, 17 Apr 2023 18:38:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by sourceware.org (Postfix) with ESMTPS id 3A5973857716 for ; Mon, 17 Apr 2023 18:37:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A5973857716 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-yw1-x1129.google.com with SMTP id 00721157ae682-54fa9da5e5bso227731897b3.1 for ; Mon, 17 Apr 2023 11:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681756626; x=1684348626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=kk2WGDXFeHiGM8032nSpYvQDeqnXR2eC4cAWeTz8dgE=; b=T0yPD3+t/mFZCE/Q5pJ/grc3ADI5H2X7EZlbJ64xJZJIDx7EfzW6zsh0V0lEnOMX9g a+kTs+BLA5Pi1mXT/RuNj9ikng0+afTgBQbgnfNGq5jhg5pydcHy5lLjSesXZAspsRWv Hm90+ch1TB7Y2GmRC0YSmr7gVeRCPs3Z9rmCHTHUHa9qkXLtbTdUUEGIqpCwmuPq12Mc g1LAYM4BNV+7b2jfBLPN8OeJ7wtcXJqnUFlmiVQvdPh7zmhcf9QC1Tik2g8dmWxBTJf2 hyOC/ZmVoETsqCiYkhNn8cSVkOd6avMyiE6WEcR9qFCY0mPljplnQGF+WxDWtpgXpSAS zq3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681756626; x=1684348626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kk2WGDXFeHiGM8032nSpYvQDeqnXR2eC4cAWeTz8dgE=; b=bi5D59aElOS1KknMu3CgPQifiMk6iRjaJnTJd8MMnCqNpw9mfkOEN+VBZVMEZabWlw 7qbSY+wu/LqzI4JyEHwYCxdiqrru0J0kEwXU/Wl9EXTl79sCGC0fAkzoej+905DQuJoH AP22K1xOxxXk9APgnZkhPl5b/FD4acuZ5KNyuv6Z7HOUWH6oMnngIzC1LOS2E/l2gbLO L3U7ilDVCaZcBq0Ztza+43JiQEURRA/TH4Lpv0wBm9Fq8wgCz0P00Fml6viKd8Ukczjq k1g+0p6umDMy4V+iTdm8vrBoegqDK357J62/AANylWAB6/zXuZflPX460dEOrg6mX8n5 td9A== X-Gm-Message-State: AAQBX9eYe4a/BXqdTgI/rr/YjY/2riVHDCNP5LzsbSxuXiCQAzYSa6RZ 5Q9J3e4REPphAsJjnlNM/thIaxX16DpBQsfA7VtqtQ== X-Received: by 2002:a0d:d954:0:b0:54f:93ec:e504 with SMTP id b81-20020a0dd954000000b0054f93ece504mr15194034ywe.6.1681756626491; Mon, 17 Apr 2023 11:37:06 -0700 (PDT) Received: from system76-pc.ba.rivosinc.com ([136.57.172.92]) by smtp.gmail.com with ESMTPSA id 66-20020a810645000000b0054f6f65f258sm3278559ywg.16.2023.04.17.11.37.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 11:37:06 -0700 (PDT) From: Michael Collison To: gcc-patches@gcc.gnu.org Subject: [PATCH v4 07/10] vect: Verify that GET_MODE_NUNITS is a multiple of 2. Date: Mon, 17 Apr 2023 14:36:58 -0400 Message-Id: <20230417183701.2249183-8-collison@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230417183701.2249183-1-collison@rivosinc.com> References: <20230417183701.2249183-1-collison@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, 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 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?1763449984494843423?= X-GMAIL-MSGID: =?utf-8?q?1763449984494843423?= While working on autovectorizing for the RISCV port I encountered an issue where can_duplicate_and_interleave_p assumes that GET_MODE_NUNITS is a evenly divisible by two. The RISC-V target has vector modes (e.g. VNx1DImode), where GET_MODE_NUNITS is equal to one. Tested on RISCV and x86_64-linux-gnu. Okay? 2023-03-09 Michael Collison * tree-vect-slp.cc (can_duplicate_and_interleave_p): Check that GET_MODE_NUNITS is a multiple of 2. --- gcc/tree-vect-slp.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index d73deaecce0..a64fe454e19 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -423,10 +423,13 @@ can_duplicate_and_interleave_p (vec_info *vinfo, unsigned int count, (GET_MODE_BITSIZE (int_mode), 1); tree vector_type = get_vectype_for_scalar_type (vinfo, int_type, count); + poly_int64 half_nelts; if (vector_type && VECTOR_MODE_P (TYPE_MODE (vector_type)) && known_eq (GET_MODE_SIZE (TYPE_MODE (vector_type)), - GET_MODE_SIZE (base_vector_mode))) + GET_MODE_SIZE (base_vector_mode)) + && multiple_p (GET_MODE_NUNITS (TYPE_MODE (vector_type)), + 2, &half_nelts)) { /* Try fusing consecutive sequences of COUNT / NVECTORS elements together into elements of type INT_TYPE and using the result @@ -434,7 +437,7 @@ can_duplicate_and_interleave_p (vec_info *vinfo, unsigned int count, poly_uint64 nelts = GET_MODE_NUNITS (TYPE_MODE (vector_type)); vec_perm_builder sel1 (nelts, 2, 3); vec_perm_builder sel2 (nelts, 2, 3); - poly_int64 half_nelts = exact_div (nelts, 2); + for (unsigned int i = 0; i < 3; ++i) { sel1.quick_push (i);