From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id D81673858D28 for ; Tue, 1 Aug 2023 11:18:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D81673858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BA4B1D75; Tue, 1 Aug 2023 04:19:32 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 43DB73F6C4; Tue, 1 Aug 2023 04:18:48 -0700 (PDT) From: Richard Sandiford To: Jeff Law via Gcc-patches Mail-Followup-To: Jeff Law via Gcc-patches ,Xiao Zeng , Jeff Law , research_trasio@irq.a4lg.com, kito.cheng@gmail.com, zhengyu@eswincomputing.com, eri-sw-toolchain@eswincomputing.com, richard.sandiford@arm.com Cc: Xiao Zeng , Jeff Law , research_trasio@irq.a4lg.com, kito.cheng@gmail.com, zhengyu@eswincomputing.com, eri-sw-toolchain@eswincomputing.com Subject: Re: [PATCH 2/5] [RISC-V] Generate Zicond instruction for basic semantics References: <20230719101156.21771-1-zengxiao@eswincomputing.com> <20230719101156.21771-3-zengxiao@eswincomputing.com> Date: Tue, 01 Aug 2023 12:18:47 +0100 In-Reply-To: (Jeff Law via Gcc-patches's message of "Wed, 26 Jul 2023 11:53:42 -0600") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-20.3 required=5.0 tests=BAYES_00,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,KAM_SHORT,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Jeff Law via Gcc-patches writes: > On 7/19/23 04:11, Xiao Zeng wrote: >> This patch completes the recognition of the basic semantics >> defined in the spec, namely: >> >> Conditional zero, if condition is equal to zero >> rd = (rs2 == 0) ? 0 : rs1 >> Conditional zero, if condition is non zero >> rd = (rs2 != 0) ? 0 : rs1 >> >> gcc/ChangeLog: >> >> * config/riscv/riscv.md: Include zicond.md >> * config/riscv/zicond.md: New file. >> >> gcc/testsuite/ChangeLog: >> >> * gcc.target/riscv/zicond-primitiveSemantics.c: New test. > So I played with this a bit today. I originally thought that using > match_dup was the right way to go for those 4 secondary patterns. But > after further pondering it's not ideal. > > match_dup will require pointer equality within the RTL structure. That > could inhibit detection in two cases. First, SUBREGs. SUBREGs are not > shared. So we'd never match if we had a SUBREG expression. > > Second, post register allocation we can have the same looking RTX, but > it may not be pointer equal. Where were you seeing the requirement for pointer equality? genrecog.cc at least uses rtx_equal_p, and I think it has to. E.g. some patterns use (match_dup ...) to match output and input mems, and mem rtxes shouldn't be shared. I'd always understood using matching constraints against other inputs to be a no-no, since the RA doesn't (and can't reasonably be expected to) make two non-identical inputs match. So AIUI, using "1" won't lead to different code generation compared to "r". Both are relying on the RA happening to do the right thing. But "1" would presumably trigger an ICE if something goes wrong. Thanks, Richard > The SUBREG issue also means that we don't want to use a REGNO (x) == > REGNO (y) style check because those macros are only valid on REG > expressions. We could strip the SUBREG, but that's usually awkward to > do in a pattern's condition. > > The net result is we probably should use rtx_equal_p which I was hoping > to avoid. I'm testing with that change to the 4 secondary patterns > right now. Assuming that passes (and I have no reason to think it > won't) then I'll go ahead and commit #1 and #2 from this series which is > all I have time for today. > > > > Jeff