From patchwork Tue Oct 17 07:30:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 153951 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3958182vqb; Tue, 17 Oct 2023 00:31:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6HM4vR0eiNn0lI7ijIxtd5437zncQznwzNr++o5sZQorB+zhsjnY+9xMToYdl68bQ8fH3 X-Received: by 2002:ac8:5952:0:b0:415:2623:d8df with SMTP id 18-20020ac85952000000b004152623d8dfmr1761132qtz.7.1697527872279; Tue, 17 Oct 2023 00:31:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697527872; cv=pass; d=google.com; s=arc-20160816; b=H7Q8XxiAhEb5HuUl0K3HcLJoINkJep6TE866ayCVp2QPVqI9/zqJYHQlEDN+OEDFUu 9nyvsaOZb3TqYx1faZmHgnJFI+OvhDXdNf7BQ7LG21UG0lVo26ilO4/ULxS4FOtPMru4 xMeKWQVraOgNTfYHgVW+NqY3L2N7xsK4VpmBdxudUPHSpzysW3XO66lN+5raw6Bilj6i EXA8Zsa89qjYpIYLfzFqZ0BQfyw9PmJmYhhHeun/4UZS0rV9u0DNBVbeFATAj2uj5TQS pzPirAMY9R44bgdKhEyqiBhvo9vPolhM21rwCx9YUyreFgDXZAHrLqNQ/K7JPfnOpSfQ Bl8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:arc-filter:dmarc-filter:delivered-to; bh=EwgVZvCVYux9qW7oxUhO54esjVuXkivt0xb/HI/sEmg=; fh=12MRPJmZ1mgDpHqWoogMKqnaGRGM2b7lcuJroqfjJiw=; b=ZYsrNs0YiiODYFxA4SGlHk64gM5LZwKBnuhop9ixx8vRemQSyZCevO1VXjj8yPCBEI +rFUmLRjzy6HJmRqfnWxAcn5ajhvfxKcSfjFkmJc2od96B/fpYVvLlTNGDa7jaxjDaAu 5DIvpfg+tkFORxh1IKiVhjpwvZDe7Vb6nwhlFak42xFSz8m2yXdJip6//BB3y5rjOJjr e7bYYB/xY1eat8t1u0z/FouPjRGZz8vMN7i+GufOIBaaCeSFQdGmVLaZpOZxae1V78z/ IAZSAa2tSH7e8E+mvzwVKd+1EFX4pWHVv7M/BPW1aAeJelXFilWgK+uxYPphTKSFHUIT iqvg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e17-20020ac84e51000000b00417931c4b8csi738263qtw.570.2023.10.17.00.31.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 00:31:12 -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; arc=pass (i=1); 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 143A938582BD for ; Tue, 17 Oct 2023 07:31:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) by sourceware.org (Postfix) with ESMTPS id C67FF3858D33 for ; Tue, 17 Oct 2023 07:30:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C67FF3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C67FF3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=54.92.39.34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697527849; cv=none; b=O1Qynh12UI28aEZewlClNjIj1Z0QziYLN2r/mCVSDgVcpdHWTNaOX12uIqFtaguhOIc2NvVKwpjab1iNYiyEnbIj6MHpVtpSw9rgkUCwO8wXwtFF/ya9g071xbdwgu3KkeH0y4HjC4lT6yhJrbkUIHxSmKXhYEHIpeBcIGtalXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697527849; c=relaxed/simple; bh=cbp/tM+2gS2zd918ASlpIG6imMg0ti+Wxeig2VHQ5Ys=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=VQek2loA1MA0RS2QZnabVjuMKqE5iXtpnmCKWM/ssh98XTVm6FEUTJGcj11K8/BnuwENlQM86nbPs9ZpvDRUdY8uhfxMVIy344PzJHoeCdYR39yaK9P8rxT8XIQo55Q2/ePUDUcH5vFr4Tn6RwIhF/wNDPM5ursKl5RMPfLl5ZE= ARC-Authentication-Results: i=1; server2.sourceware.org X-QQ-mid: bizesmtp86t1697527841t9ch2y06 Received: from rios-cad121.hadoop.rioslab.org ( [58.60.1.9]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 17 Oct 2023 15:30:40 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: D2GZf6M6C/gGsjfLa5A8ae8BLjUJ9Z2zkiu9ROMH6NVpKzdlaUpb52ylVdqiy MDBQA72hx0RchOQz9m+AkqzGVgBx6OJxKVZfzWUQg1xswC881WNvhkfBymusgXGl575L/hq ZhWTEoiT7/a2TTp3CVStZhpUGWIzBy9irXMq/dNs5ZSnZ5fZrZn8oJPVTamk6Xv5HKiEtxo Eky6TTDX85K3piccHByqm1UTJxshFNXMA/ZJKwEWSiJ4bVullz17eGZAw+2cgmEkHio1GZG t459XItfgT5csv1P3dP7PWkebfu6MVfJWDKj8VyHf9GsA6oMIx4Vru2H6CVTfbajVjsgk4G 6uBtYac0mmUjkZiN3e0ivrAPg7m4MXtpzT4Xfti5PNNbsmBuXSnkepFsgby0y2Ml3xvCHHs JbEfxGhP5OX4kXWLfoVxSQ== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 7138175487713919891 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, kito.cheng@sifive.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Juzhe-Zhong Subject: [PATCH] RISC-V: Enable more tests for dynamic LMUL and bug fix[PR111832] Date: Tue, 17 Oct 2023 15:30:39 +0800 Message-Id: <20231017073039.1485182-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779986985934372035 X-GMAIL-MSGID: 1779986985934372035 Last time, Robin has mentioned that dynamic LMUL will cause ICE in SPEC: https://gcc.gnu.org/pipermail/gcc-patches/2023-September/629992.html which is caused by assertion FAIL. When we enable more currents in rvv.exp with dynamic LMUL, such issue can be reproduced and has a PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111832 Now, we enable more tests in rvv.exp in this patch and fix the bug. gcc/ChangeLog: * config/riscv/riscv-vector-costs.cc (get_biggest_mode): New function. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/rvv.exp: Enable more dynamic tests. --- gcc/config/riscv/riscv-vector-costs.cc | 19 +++++++++++++------ gcc/testsuite/gcc.target/riscv/rvv/rvv.exp | 10 ++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gcc/config/riscv/riscv-vector-costs.cc b/gcc/config/riscv/riscv-vector-costs.cc index 33061efb1d0..af87388a1e4 100644 --- a/gcc/config/riscv/riscv-vector-costs.cc +++ b/gcc/config/riscv/riscv-vector-costs.cc @@ -154,6 +154,14 @@ compute_local_program_points ( } } +static machine_mode +get_biggest_mode (machine_mode mode1, machine_mode mode2) +{ + unsigned int mode1_size = GET_MODE_BITSIZE (mode1).to_constant (); + unsigned int mode2_size = GET_MODE_BITSIZE (mode2).to_constant (); + return mode1_size >= mode2_size ? mode1 : mode2; +} + /* Compute local live ranges of each vectorized variable. Note that we only compute local live ranges (within a block) since local live ranges information is accurate enough for us to determine @@ -201,12 +209,12 @@ compute_local_live_ranges ( { unsigned int point = program_point.point; gimple *stmt = program_point.stmt; - machine_mode mode = biggest_mode; tree lhs = gimple_get_lhs (stmt); if (lhs != NULL_TREE && is_gimple_reg (lhs) && !POINTER_TYPE_P (TREE_TYPE (lhs))) { - mode = TYPE_MODE (TREE_TYPE (lhs)); + biggest_mode = get_biggest_mode (biggest_mode, + TYPE_MODE (TREE_TYPE (lhs))); bool existed_p = false; pair &live_range = live_ranges->get_or_insert (lhs, &existed_p); @@ -225,7 +233,9 @@ compute_local_live_ranges ( the future. */ if (is_gimple_val (var) && !POINTER_TYPE_P (TREE_TYPE (var))) { - mode = TYPE_MODE (TREE_TYPE (var)); + biggest_mode + = get_biggest_mode (biggest_mode, + TYPE_MODE (TREE_TYPE (var))); bool existed_p = false; pair &live_range = live_ranges->get_or_insert (var, &existed_p); @@ -238,9 +248,6 @@ compute_local_live_ranges ( live_range = pair (0, point); } } - if (GET_MODE_SIZE (mode).to_constant () - > GET_MODE_SIZE (biggest_mode).to_constant ()) - biggest_mode = mode; } if (dump_enabled_p ()) for (hash_map::iterator iter = live_ranges->begin (); diff --git a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp index ff76e17d0e6..674ba0d72b4 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp +++ b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp @@ -58,10 +58,12 @@ set AUTOVEC_TEST_OPTS [list \ {-ftree-vectorize -O3 --param riscv-autovec-lmul=m2} \ {-ftree-vectorize -O3 --param riscv-autovec-lmul=m4} \ {-ftree-vectorize -O3 --param riscv-autovec-lmul=m8} \ + {-ftree-vectorize -O3 --param riscv-autovec-lmul=dynamic} \ {-ftree-vectorize -O2 --param riscv-autovec-lmul=m1} \ {-ftree-vectorize -O2 --param riscv-autovec-lmul=m2} \ {-ftree-vectorize -O2 --param riscv-autovec-lmul=m4} \ - {-ftree-vectorize -O2 --param riscv-autovec-lmul=m8} ] + {-ftree-vectorize -O2 --param riscv-autovec-lmul=m8} \ + {-ftree-vectorize -O2 --param riscv-autovec-lmul=dynamic} ] foreach op $AUTOVEC_TEST_OPTS { dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/partial/*.\[cS\]]] \ "" "$op" @@ -104,18 +106,22 @@ set AUTOVEC_TEST_OPTS [list \ {-ftree-vectorize -O3 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math} \ {-ftree-vectorize -O3 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m4 -fno-vect-cost-model -ffast-math} \ {-ftree-vectorize -O3 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m8 -fno-vect-cost-model -ffast-math} \ + {-ftree-vectorize -O3 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=dynamic -ffast-math} \ {-ftree-vectorize -O2 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m1 -fno-vect-cost-model -ffast-math} \ {-ftree-vectorize -O2 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math} \ {-ftree-vectorize -O2 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m4 -fno-vect-cost-model -ffast-math} \ {-ftree-vectorize -O2 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m8 -fno-vect-cost-model -ffast-math} \ + {-ftree-vectorize -O2 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=dynamic -ffast-math} \ {-ftree-vectorize -O3 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m1 -fno-vect-cost-model -ffast-math} \ {-ftree-vectorize -O3 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math} \ {-ftree-vectorize -O3 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m4 -fno-vect-cost-model -ffast-math} \ {-ftree-vectorize -O3 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m8 -fno-vect-cost-model -ffast-math} \ + {-ftree-vectorize -O3 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=dynamic -ffast-math} \ {-ftree-vectorize -O2 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m1 -fno-vect-cost-model -ffast-math} \ {-ftree-vectorize -O2 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math} \ {-ftree-vectorize -O2 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m4 -fno-vect-cost-model -ffast-math} \ - {-ftree-vectorize -O2 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m8 -fno-vect-cost-model -ffast-math} ] + {-ftree-vectorize -O2 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m8 -fno-vect-cost-model -ffast-math} \ + {-ftree-vectorize -O2 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=dynamic -ffast-math} ] foreach op $AUTOVEC_TEST_OPTS { dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/gather-scatter/*.\[cS\]]] \ "" "$op"