From patchwork Fri Jan 19 08:34:25 2024 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: 189438 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp871227dyb; Fri, 19 Jan 2024 00:37:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXVIRcyRRMMCnsHQteTs1YlzIXodx49ql7jCO1nf7fVHFz1zXmjugPDU/VdSNDpDpRuFjv X-Received: by 2002:a05:6214:258f:b0:681:8787:b330 with SMTP id fq15-20020a056214258f00b006818787b330mr2359473qvb.16.1705653475977; Fri, 19 Jan 2024 00:37:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705653475; cv=pass; d=google.com; s=arc-20160816; b=OCkbApIakgiQRCpb269weXECiJoqrZrQh1ZgM/d6QfmufzPfrHuasprSqs0kk4zDhN 6cw920X56ybmhiWYEkcAR1LRbR4XCMgYViBJOIOk7eOxfJnd8gj9aUrI60GY3hMn+vT0 sjq72Tm6UuJrG2SUDasb81aI12nR+FnYlkfB5JXEfQzjI2pKYfXOYvQPkITqpOrqLCda 52yX4iHSYKVji9Q38d5nR4YssYmKcYBdOnCZNBi8XkfKfFDk4Acqyy9u4f/kxcOVP8O0 fITmq5lQhtLX8BhqLSKxbXzrSvHnFTmSrq1iv0OS2G8l/GUb7zWmsZtTXd4WSVnClEjC Zwsw== 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=bTL/UmAU1RJ4gQjhChJVoUArda5uTo95VEWAbnAXiDw=; fh=12MRPJmZ1mgDpHqWoogMKqnaGRGM2b7lcuJroqfjJiw=; b=zj3R1n5whshBOt/54fJgffElCI31XniwwyZElvJFw0973lXYS963Q+6DSfSkewIoxA eK60c6DpT5h4KRTakdxXkkkYUHCOEuIml7Hj5Yqn6jTwvS0MwF3i0YpF0wq1GvVbgetp +frJKDU7kb/4Q6uvWcwS/NZ5SsxmdUV3oolXSWGPHRRhn5YsZc/Q3FSq1CLBcldvEPmU XQmykt82Yz9CU/mEYWBhLAkxMtLQ0EihAoeoQTIX87zRwGTyhq2Cfs2gBA9koiMi/uZW W1QUOr3REfKfB2vlDTZTMJBlV/KsCo1epIi7bhNCc6Mnb0DJ/93EX3G5hZzpAkHkkpyH E5Tg== 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 u7-20020a0c8dc7000000b0067f49266101si15519730qvb.477.2024.01.19.00.37.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 00:37:55 -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 8F7523858412 for ; Fri, 19 Jan 2024 08:37:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) by sourceware.org (Postfix) with ESMTPS id A4C203858C74 for ; Fri, 19 Jan 2024 08:34:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4C203858C74 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 A4C203858C74 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=54.243.244.52 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705653282; cv=none; b=SIoKhCpwS7Cc+jQEUnDM9aD6e6JrOy1Cc3GVolIVkTz2NjhrZv+Ri9sxZmhG7R71FLXnCSl7CTuXCayhMZwRDTtJ07a6/VFFPocLyabqLcA7j+lzJX+a2/vgmaLKycUcluQ7qezwNhWB6O+VYyqo7L7yyYfMu/RvY6jHlxkS0Tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705653282; c=relaxed/simple; bh=5XsDdYUseex4ZTrkN6cMDY0U6mL9LPdBfRb+df7P1ZA=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=dxkoOQzbdHt4C534zxFEpYfI0WX2dpzo0RqwupCl1+n6QWkNzph7ar0CBjWQGAzvAHn+dv6E0Y99gOBjydMTCKmnL/7CPlbRfIViaSX0u9tgfLUDXy48kpPu/nAjjvt6b9xupihlrT9MEZuGdskC2QthEtvBB2PoIX+IFiOoj3c= ARC-Authentication-Results: i=1; server2.sourceware.org X-QQ-mid: bizesmtp69t1705653268t125ohs9 X-QQ-Originating-IP: CVA9NyY/mQA2P2OxZY1c9LRT7ZMpyhusUTPRxS9184I= Received: from rios-cad122.hadoop.rioslab.org ( [58.60.1.26]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 19 Jan 2024 16:34:26 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: rGm7xzoh3hkx47e/T+FG0jK5930IvlHLpyNUf4puvKITvR6MxeXzulqFhoXKH Q/VVwPomAiPjH2eIRpjC8Kt34NdsD4SIBAX8eC9Jd6tpTXs+kEE02VDN5mHeQQ09e+SD0Py iIk4HWxWQH0FBVn7ECepYIsgiIYntssrzrZGnl283e40RKqe1GrLNaC/K1/1k/mPWtTU5pK 87IGD1kTJ+PqSlHUz8+wHJNzQEAO6MMFNTPMFkJrd77qJ2EmCaoFSKKHw4Rp8slIpLWdQM5 o8NWumJjn7F+t6pEL3eohRaDK44bkxseLRPGTxYv8qDFOQvq3FtVn9KDfUs0xsYPmjefGzq jHzNLL8pHAoewkJ4N1+28HfPSvTCwga2nFxirDyWefmR3Xw7MYaUj4eRDLnayd/dVH6W959 dnWEMoXXH6A= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 1868190677960984522 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 V2] RISC-V: Fix RVV_VLMAX Date: Fri, 19 Jan 2024 16:34:25 +0800 Message-Id: <20240119083425.3358063-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=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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.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: 1788507299337138065 X-GMAIL-MSGID: 1788507299337138065 This patch fixes memory hog found in SPEC2017 wrf benchmark which caused by RVV_VLMAX since RVV_VLMAX generate brand new rtx by gen_rtx_REG (Pmode, X0_REGNUM) every time we call RVV_VLMAX, that is, we are always generating garbage and redundant (reg:DI 0 zero) rtx. After this patch fix, the memory hog is gone. Time variable usr sys wall GGC machine dep reorg : 1.99 ( 9%) 0.35 ( 56%) 2.33 ( 10%) 939M ( 80%) [Before this patch] machine dep reorg : 1.71 ( 6%) 0.16 ( 27%) 3.77 ( 6%) 659k ( 0%) [After this patch] Time variable usr sys wall GGC machine dep reorg : 75.93 ( 18%) 14.23 ( 88%) 90.15 ( 21%) 33383M ( 95%) [Before this patch] machine dep reorg : 56.00 ( 14%) 7.92 ( 77%) 63.93 ( 15%) 4361k ( 0%) [After this patch] Test is running. Ok for trunk if I passed the test with no regresion ? PR target/113495 gcc/ChangeLog: * config/riscv/riscv-protos.h (RVV_VLMAX): Change to regno_reg_rtx[X0_REGNUM]. (RVV_VUNDEF): Ditto. * config/riscv/riscv-vsetvl.cc: Add timevar. --- gcc/config/riscv/riscv-protos.h | 5 ++--- gcc/config/riscv/riscv-vsetvl.cc | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index 7853b488838..7fe26fcd939 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -299,10 +299,9 @@ void riscv_run_selftests (void); #endif namespace riscv_vector { -#define RVV_VLMAX gen_rtx_REG (Pmode, X0_REGNUM) +#define RVV_VLMAX regno_reg_rtx[X0_REGNUM] #define RVV_VUNDEF(MODE) \ - gen_rtx_UNSPEC (MODE, gen_rtvec (1, gen_rtx_REG (SImode, X0_REGNUM)), \ - UNSPEC_VUNDEF) + gen_rtx_UNSPEC (MODE, gen_rtvec (1, RVV_VLMAX), UNSPEC_VUNDEF) /* These flags describe how to pass the operands to a rvv insn pattern. e.g.: diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index 2067073185f..54c85ffb7d5 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -3556,7 +3556,7 @@ const pass_data pass_data_vsetvl = { RTL_PASS, /* type */ "vsetvl", /* name */ OPTGROUP_NONE, /* optinfo_flags */ - TV_NONE, /* tv_id */ + TV_MACH_DEP, /* tv_id */ 0, /* properties_required */ 0, /* properties_provided */ 0, /* properties_destroyed */