From patchwork Mon Aug 14 09:42:18 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: 135283 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2628425vqi; Mon, 14 Aug 2023 02:43:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDjrrYpt14dpaRz+kvbg0zYqot0sovSkDgqsjoIqz4kNE/239M1SKB/cT9/TzLOMj0QKKV X-Received: by 2002:aa7:d7da:0:b0:525:63f9:a268 with SMTP id e26-20020aa7d7da000000b0052563f9a268mr1880938eds.42.1692006190313; Mon, 14 Aug 2023 02:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692006190; cv=none; d=google.com; s=arc-20160816; b=G024C3xBtHP8IbkNOAnTD3oVpu/qBuuLdUDbYvFD/sdaLFixie1IEmoertufJtHRdk bcugRBYjCdqkFx2vED7Dtgv793GGtO5IBVyBdfhyXhkoPdtpb5uLC2usJ7TjaOwowCWm jZitoacBpe7GLuQ1CvMp0wrHMkjFowmMP509DYiGqMuMWc/bIlzzbgN4Maczccs+WoNF dxgXd2/dJarnxlu99uXNcVlDKhawFKwiEz7KenvyMTEfmrJyuRx9l3Tj0u5VmCNpzSv4 WtVfhLO9TpurvuPGuSxscReeMafX2ptPh8dkgp6ZsH4wzSMUu+u/sCy+OIz09inlcTIT LvZw== 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=ckz1MQM8r0nOwKmahTFOqBLi9xrBZ2P2YL77Ui1pPS8=; fh=ztTaNOoO2vBH2irxLNQKWGUTd4S0elIJH0F2n3HDG38=; b=TQOCqS+W/gaOOBXNgbeZ61RWeS9ebHEJuY6ajseSQENXmVW3ImaCbZ0omtxlgcOFFB t+SDfm3NiYy1EftbehuSC6hnxzsjwvCew8nUyuA/Ae+fMqaxcr74ffXm8gD2obS7XMMz r2XZj2WQCXQ1amsSLU3q7uL1ekZJC9US/QqxBcE8QN5rBVFCOGXy2OT8S6mwvD/MdZAn gstuKTkwOkqolaxPdZvq0B0vP6b3WL3xV4KjAMRbIWQboUwHgjNIcu0NWvPkfZwhKMG3 O27AXtHM8vg0X6PZoAhAyVAsZG3kc0EpmZRFut8Bk2sRwtz2CDZ1VnMwTXdCw/X5w5uk aycw== 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 server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g16-20020a50ee10000000b005255bb59aeasi2249155eds.560.2023.08.14.02.43.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 02:43:10 -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; 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 847AB385841B for ; Mon, 14 Aug 2023 09:43:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) by sourceware.org (Postfix) with ESMTPS id 592603858D39 for ; Mon, 14 Aug 2023 09:42:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 592603858D39 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: bizesmtp73t1692006140twgb30ys Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 14 Aug 2023 17:42:19 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: 2aGsoZ9h879bAoPxMYL2ZQAKhRTpHzDcCNOx/DmUC+/q5mhFmyzDlEkXcPMhS +J5pL9HBl9++iWwAOclOcCJwO3zgugbCZnBvZLdoHdPq7IvQJOmm3CsxKX1HpahmTq0exjW KV7knR9JxXquSeTJmwgldOGUCd/W7mjcRp9lqnIJ6V4O08zvrOgeD6q3ODqzdIeayX2mt/9 9OqTbesMB4dwkUh91RtAdMTtXxmWvrd0Nb2flmBcJF8+vI9i4SUF8Qd7K89UBoQCigh6iP4 euwJNINptgWJIwdaJ/R0BOedCJXz173sY45V8Ne93lcVe9Y+7Sp1c4wmIwV/i26Mos9ew3h G48bvkewUKhi01fhLmmr79Y3t6u17jW73wb4AVRZM4IwsgaZcF7tAwBQin2RE43Pl8bJy4G 0jZQT/rxihxNxASQwQwO6Q== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 7408857987441111811 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, rguenther@suse.de, jeffreyalaw@gmail.com, Juzhe-Zhong Subject: [PATCH] genrecog: Add SUBREG_BYTE.to_constant check to the genrecog Date: Mon, 14 Aug 2023 17:42:18 +0800 Message-Id: <20230814094218.3286920-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.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, TXREP, T_SPF_HELO_TEMPERROR, WEIRD_PORT 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: INBOX X-GMAIL-THRID: 1774197083305420037 X-GMAIL-MSGID: 1774197083305420037 Hi, there is genrecog issue happens in RISC-V backend. This is the ICE info: 0xfa3ba4 poly_int_pod<2u, unsigned short>::to_constant() const ../../../riscv-gcc/gcc/poly-int.h:504 0x28eaa91 recog_5 ../../../riscv-gcc/gcc/config/riscv/bitmanip.md:314 0x28ec5b4 recog_7 ../../../riscv-gcc/gcc/config/riscv/iterators.md:81 0x2a2e740 recog_436 ../../../riscv-gcc/gcc/config/riscv/thead.md:265 0x2a729ef recog_475 ../../../riscv-gcc/gcc/config/riscv/sync.md:509 0x2a75aec recog(rtx_def*, rtx_insn*, int*) ../../../riscv-gcc/gcc/config/riscv/iterators.md:55 0x2b3e39e recog_for_combine_1 ../../../riscv-gcc/gcc/combine.cc:11382 0x2b3f457 recog_for_combine ../../../riscv-gcc/gcc/combine.cc:11652 0x2b25a15 try_combine ../../../riscv-gcc/gcc/combine.cc:4054 0x2b1d3f1 combine_instructions ../../../riscv-gcc/gcc/combine.cc:1266 0x2b48cfc rest_of_handle_combine ../../../riscv-gcc/gcc/combine.cc:15063 0x2b48db8 execute ../../../riscv-gcc/gcc/combine.cc:15107 This is because the genrecog code here cause ICE for scalable vector in RISC-V: Before this patch: static int recog_5 (rtx x1 ATTRIBUTE_UNUSED, rtx_insn *insn ATTRIBUTE_UNUSED, int *pnum_clobbers ATTRIBUTE_UNUSED) { rtx * const operands ATTRIBUTE_UNUSED = &recog_data.operand[0]; rtx x2, x3, x4; int res ATTRIBUTE_UNUSED; if (pnum_clobbers == NULL) return -1; x2 = XEXP (x1, 1); x3 = XEXP (x2, 0); if (maybe_ne (SUBREG_BYTE (x3).to_constant (), 0) ---> this code cause ICE. || GET_MODE (x3) != E_SImode || !register_operand (operands[0], E_DImode) || GET_MODE (x2) != E_DImode) return -1; ... This ICE happens since we have following RTL IR: (insn 27 26 29 4 (set (reg:RVVM1HI 155 [ vect__12.23 ]) (sign_extend:RVVM1HI (subreg:RVVMF2QI (reg:RVVMF2x2QI 146 [ vect_array.19 ]) [8, 8]))) "auto.c":29:1 discrim 2 12570 {extendrvvmf2qirvvm1hi2} (expr_list:REG_DEAD (reg:RVVMF2x2QI 146 [ vect_array.19 ]) (nil))) This is the scalable vector with SUBREG_BYTE = poly (8, 8) After this patch: static int recog_5 (rtx x1 ATTRIBUTE_UNUSED, rtx_insn *insn ATTRIBUTE_UNUSED, int *pnum_clobbers ATTRIBUTE_UNUSED) { rtx * const operands ATTRIBUTE_UNUSED = &recog_data.operand[0]; rtx x2, x3, x4; int res ATTRIBUTE_UNUSED; if (pnum_clobbers == NULL) return -1; x2 = XEXP (x1, 1); x3 = XEXP (x2, 0); if ((SUBREG_BYTE (x3).is_constant () && maybe_ne (SUBREG_BYTE (x3).to_constant (), 0)) ----> change here and fix ICE. || GET_MODE (x3) != E_SImode || !register_operand (operands[0], E_DImode) || GET_MODE (x2) != E_DImode) return -1; Does it reasonable ? Thanks. gcc/ChangeLog: * genrecog.cc (print_test): Add SUBREG_BYTE.to_constant () check. --- gcc/genrecog.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/genrecog.cc b/gcc/genrecog.cc index 04a5533ca4b..28884ab3985 100644 --- a/gcc/genrecog.cc +++ b/gcc/genrecog.cc @@ -4705,11 +4705,14 @@ print_test (output_state *os, const rtx_test &test, bool is_param, break; case rtx_test::SUBREG_FIELD: + printf ("(SUBREG_BYTE ("); + print_test_rtx (os, test); + printf (").is_constant () && "); printf ("%s (", invert_p ? "maybe_ne" : "known_eq"); print_nonbool_test (os, test); printf (", "); print_label_value (test, is_param, value); - printf (")"); + printf ("))"); break; case rtx_test::SAVED_CONST_INT: