From patchwork Sat Dec 24 03:08:00 2022 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: 36384 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6000:1b02:0:0:0:0 with SMTP id f2csp86052wrz; Fri, 23 Dec 2022 19:08:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXvk3RkS/TP8SXGwZ/JpPaB8e/Bb89EJvJMR3BAkBEhvklHQDkh5Eg1xN8KjNSficHEuMOdz X-Received: by 2002:a17:906:6d97:b0:78d:f455:c386 with SMTP id h23-20020a1709066d9700b0078df455c386mr9400385ejt.44.1671851324110; Fri, 23 Dec 2022 19:08:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671851324; cv=none; d=google.com; s=arc-20160816; b=S1zGBTOd9VbwR5m8IjgAUhzAZ+5doYYj7ux7U0c9Bd1U/30s3mNxyvjfXNCNk8SLmj IwPTvYB0sCESM8Ayx9q82qG43bQUPoudy4RYXwxyQsfTOTxuFf9EdjOHZFez4ZJAPs82 aREecyxmsz+KIWMHIlmjiEoYFS46I2Oo0pi0Ww0OM+zqn6eZWenl3WGpZn26+OarMcBZ b07zCyI5k9kTcfJM/P3iN0BjUW3rf3UBXcZxUZTwDdRXz23XY8R90xVd/a9r6U5tFIDj AI567pgDsLsvCTFOplWgvP685IA0vrRLE4h6D4k3AmgsSNhWneZVjjHVDK56rc2p9cfJ XD+g== 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:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dmarc-filter:delivered-to; bh=wME2vnhM+9s3RJT2fCQw/VQ5RXyo+2CjgIbs+C78tlc=; b=qbwDw6tLcQyUBe+/2+nixfnmWC13RJ6gVJaPqBcBSps7vt1INfHbPwcIm46VJFtau2 pnD08B+Hg4R5SR644YhnyFKVEPCptUvzjjB05v3Fcp+90NGd9BZkQK08iVzfn5IBYrtI JHKpmmHIyK/eq+jsUCO4UiDhbQcSYAWWPYowVWai90/LPG38dPeBedXGadsqaAaw7u2w N8VbOaMWJIl0gE1e4ZVvEK3vB/hZFLAufN8uhOVDYgOq0SKL6oP7ffKKS0u+N73DKCIP 4SXwiP2SJRd0teSb8hpKDUQSOeXH8SzTWOzh64wQdlsPGULZTrGzHvngsEIT1RETBI+W vDWg== ARC-Authentication-Results: i=1; mx.google.com; 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 sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id xg11-20020a170907320b00b007c14e98e3a1si3925702ejb.752.2022.12.23.19.08.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Dec 2022 19:08:44 -0800 (PST) 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; 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 1FAE3385483F for ; Sat, 24 Dec 2022 03:08:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) by sourceware.org (Postfix) with ESMTPS id E84D83858D1E for ; Sat, 24 Dec 2022 03:08:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E84D83858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp62t1671851283tceco9mj Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 24 Dec 2022 11:08:02 +0800 (CST) X-QQ-SSF: 01400000000000E0L000000A0000000 X-QQ-FEAT: znfcQSa1hKaKeZ4NthzcgDZ2qNiZyHtDcZb6JTTY47kUnqD5zjBON5qNlc+64 as6LBWIrOTvxcFPVOq9TO39zcB2jALNHZGPFezpFjp4rbuntQMlGy1tANG/R85UM16T9Iig JPgQYcKJIJ8FsRbIm6Y9qHSZdjF+NhZ+wWqG1hj6uM+JG34NbDP81oPozU+jYyB4OgEjp+T D2teauHVkNzEaaRDaRksaHcOHCg1DMEXlcJdtG6wTXC6qeGHnG+BTN5dFn8b9G1oKhsculs ZP3yNSD/IpAisdns4z6mkMkjFS1iOOc6i3D+Z2OkyOR/k7NaY01gGSVQRyKUJihSOuecVLn e6PDGX103OEoGWOQLzbIJt6vfeE56pMAqELMGjNSdbFxBvZ5fik5FF0escyKA== X-QQ-GoodBg: 2 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, Ju-Zhe Zhong Subject: [PATCH] RISC-V: Fix ICE of visiting non-existing block in CFG. Date: Sat, 24 Dec 2022 11:08:00 +0800 Message-Id: <20221224030800.221397-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:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-12.6 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.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?1753063174170646148?= X-GMAIL-MSGID: =?utf-8?q?1753063174170646148?= From: Ju-Zhe Zhong This patch is to fix issue of visiting non-existing block of CFG. Since blocks index of CFG in GCC are not always contiguous, we will potentially visit a gap block which is no existing in the current CFG. This patch can avoid visiting non existing block in CFG. I noticed such issue in my internal regression of current testsuite when I change the X86 server machine. This patch fix it: 17:27:15 job(build_and_test_rv32): Increased FAIL List: 17:27:15 job(build_and_test_rv32): FAIL: gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-46.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (internal compiler error: Segmentation fault) gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (pass_vsetvl::compute_global_backward_infos): Change to visit CFG. (pass_vsetvl::prune_expressions): Ditto. --- gcc/config/riscv/riscv-vsetvl.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index a55b5a1c394..0d66765e09c 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -1962,12 +1962,10 @@ pass_vsetvl::compute_global_backward_infos (void) if (dump_file) { fprintf (dump_file, "\n\nDirty blocks list: "); - for (size_t i = 0; i < m_vector_manager->vector_block_infos.length (); - i++) - { - if (m_vector_manager->vector_block_infos[i].reaching_out.dirty_p ()) - fprintf (dump_file, "%ld ", i); - } + for (const bb_info *bb : crtl->ssa->bbs ()) + if (m_vector_manager->vector_block_infos[bb->index ()] + .reaching_out.dirty_p ()) + fprintf (dump_file, "%d ", bb->index ()); fprintf (dump_file, "\n\n"); } } @@ -1976,15 +1974,16 @@ pass_vsetvl::compute_global_backward_infos (void) void pass_vsetvl::prune_expressions (void) { - for (size_t i = 0; i < m_vector_manager->vector_block_infos.length (); i++) + for (const bb_info *bb : crtl->ssa->bbs ()) { - if (m_vector_manager->vector_block_infos[i].local_dem.valid_or_dirty_p ()) + if (m_vector_manager->vector_block_infos[bb->index ()] + .local_dem.valid_or_dirty_p ()) m_vector_manager->create_expr ( - m_vector_manager->vector_block_infos[i].local_dem); - if (m_vector_manager->vector_block_infos[i] + m_vector_manager->vector_block_infos[bb->index ()].local_dem); + if (m_vector_manager->vector_block_infos[bb->index ()] .reaching_out.valid_or_dirty_p ()) m_vector_manager->create_expr ( - m_vector_manager->vector_block_infos[i].reaching_out); + m_vector_manager->vector_block_infos[bb->index ()].reaching_out); } if (dump_file)