From patchwork Wed Nov 15 07:15:08 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: 165192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2369755vqg; Tue, 14 Nov 2023 23:15:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNaM2M5oASmgq47Mr1gA+5u0jbdGZJd+gmihhSEg4VC/qQV3/ixC7Ps6f5ZWtvPh7raxIW X-Received: by 2002:a05:622a:5cc:b0:41c:e92a:c604 with SMTP id d12-20020a05622a05cc00b0041ce92ac604mr6023223qtb.59.1700032545250; Tue, 14 Nov 2023 23:15:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700032545; cv=pass; d=google.com; s=arc-20160816; b=QZx9r4wibAu5LKZ2kM67LMPvCnre7odufdaBqteDYKn+U0y8yIuG+kiJnUdYjcEGNq l3YB7H29+AB8y4zIMATrXmrmt+AZaVimWlL1adhZ3ALmdB4KzkDWTyYdhtZkCM9IAugt mVK0WiwbW/DdnaHeZ0/Db5cAN3LXR4QF2pvy1d9Ecnv0nSFDY53/dw6JqX2Xe1EHIn2r C8VKPyeNBIM/Y0Llwo5kh2ttXQgD4FdzFgYg2db3vbhEyS/eqY8s+RW+2yFhTPdAmBfF Rt/tNPp3gQfadPRdDRGwtgFbLcfRZ0vDOi8JCPpKqLQw5UJHJ5AkkrKxMR2uEzIHCif4 TRqA== 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=argKfLO+HYjhahvVPJG75ppS8jXvjj9j0ft+BxoRbVU=; fh=12MRPJmZ1mgDpHqWoogMKqnaGRGM2b7lcuJroqfjJiw=; b=OnFkI4uf1PaL3WUGYyFNAYBY3jmmDwg3kzK0YGXzJTpdwhOuTEIE9PJyCIpO7YRc8z T1/B3/b+2KS+IzF+yY4mFU5oHevcSvffoa5vd7a1zaLEMPDDE3uuEbkgVBPbrUCojziG JIjzv6jlBN079CqCb3k0gCsoFGFhGM0bEcaNQcKr5Vf0jPzkSpgFHAfg1hlON9NnAMB0 4RsRSMDmkj6LBEjKAbXl1ha+j51tBxVhq9uQJvaANtGew2D5CFAqH6weJORaDl0pRXXw WtThooBb9L+rAWuRirH4/xce4fYJsW+LAX72BLCaUMg68lGLr4TSW/6AvoGX+Nhpf8ZQ fw4g== 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 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i13-20020ac85e4d000000b004198eef7e34si8282948qtx.84.2023.11.14.23.15.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 23:15:45 -0800 (PST) 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; arc=pass (i=1); 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 02D323858408 for ; Wed, 15 Nov 2023 07:15:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) by sourceware.org (Postfix) with ESMTPS id 359EF3858D20 for ; Wed, 15 Nov 2023 07:15:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 359EF3858D20 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 359EF3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=18.194.254.142 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700032523; cv=none; b=c8szQtFP0Rbc11tYpT0+5Oo65fX4wha9MNUlo2DYhESYcT6/LXZfFTtV0ezfqYBfYyTR7ufmwYJqygMLL7+qZBfsNqzUzFGVCuLIe3f+J89PNYxPDP6ysHX7CTLmZmwRY36xbEy50sjbtT4Wiow2JT7WU0rsnwp0/Mz5Q7jArMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700032523; c=relaxed/simple; bh=eLVluPhAn0ZMFKWe/Q8IGwRiNnR2678PkLikARUGxi8=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=m0qpdex9zwYuldc9tnUFsr2JsHKeUZmiYnBAE+ku9GtKMPgLPiF5Y92oSkgOYU6XswtvQmeoqHcLliwcm0ByvJDdv7JcxO6Vmoz3l9qzhmKXm/iiUpVsAWS45TpTouPo/yuE8yySV5/LOpD4IbmxvLqbxrErxpO6+cAOl3W9R8s= ARC-Authentication-Results: i=1; server2.sourceware.org X-QQ-mid: bizesmtp77t1700032511ta4cfify Received: from rios-cad121.hadoop.rioslab.org ( [58.60.1.9]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 15 Nov 2023 15:15:10 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: W+onFc5Tw4OXKeEH0uOuOoxS+f1ygv+PdKQm//+2rjreNhj5dzXQz3bwTINgP FkZxxRIwt5ziyljNdpQEc6Ru6titjJWJsbxarkD0VFhXKJDToaaD6TSBQ4pfQpIWUkAes/9 gBgZMDCI0Z/0V3TMhR/WMRNBj0SRn/CVO3el2b9tmwgw1eET29j2KVYSpx07z8nFiq1Fy71 6gdWmdVpEcpqmKQcwWrGr1yzoxpxo1ozTraN3o8F/HYZ18zC8mq3RsWSDK31cZgWq8r3cfi c5Gf6pZfbX53uyXkqNQNOG2ovTatrOx+LFPzDy21JWf1qyN/9KnLyAK3046WKsgbyHEPysc BbUT3QaQseOzH9h/cGG4giz//G09wjUpGRSMrtXXKSalLvwLopUT8xOizCcdo22d7Ud+5Xg pbhmwITKt6Q= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 12550123595667443168 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: Disallow RVV mode address for any load/store[PR112535] Date: Wed, 15 Nov 2023 15:15:08 +0800 Message-Id: <20231115071508.3273813-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=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, T_SPF_HELO_TEMPERROR, URIBL_BLACK 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: 1782613325935241844 X-GMAIL-MSGID: 1782613325935241844 This patch is quite obvious patch which disallow for load/store address register with RVV mode. PR target/112535 gcc/ChangeLog: * config/riscv/riscv.cc (riscv_legitimate_address_p): Disallow RVV modes base address. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/pr112535.c: New test. --- gcc/config/riscv/riscv.cc | 4 ++++ .../gcc.target/riscv/rvv/autovec/pr112535.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr112535.c diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index ecee7eb4727..e919850fc6c 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -1427,6 +1427,10 @@ static bool riscv_legitimate_address_p (machine_mode mode, rtx x, bool strict_p, code_helper = ERROR_MARK) { + /* Disallow RVV modes base address. + E.g. (mem:SI (subreg:DI (reg:V1DI 155) 0). */ + if (SUBREG_P (x) && riscv_v_ext_mode_p (GET_MODE (SUBREG_REG (x)))) + return false; struct riscv_address_info addr; return riscv_classify_address (&addr, x, mode, strict_p); diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr112535.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr112535.c new file mode 100644 index 00000000000..95799aab8d2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr112535.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */ + +int *a, *f; +char b, c; +int ***d; +static int ****e = &d; +void g() { + c = 3; + for (; c; c--) + if (c < 8) { + f = 0; + ***e = a; + } + if (b) + ***d = 0; +}