From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id C4ED73858D20 for ; Thu, 17 Feb 2022 18:50:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C4ED73858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 21HImkZi001487; Thu, 17 Feb 2022 12:48:47 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 21HImk63001486; Thu, 17 Feb 2022 12:48:46 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 17 Feb 2022 12:48:46 -0600 From: Segher Boessenkool To: Reshabh K Sharma Cc: Jeff Law , gcc-help@gcc.gnu.org Subject: Re: Describe instructions with same reg in def and use or mutiple defs and attach write latency Message-ID: <20220217184846.GN614@gate.crashing.org> References: <3b7e6310-1376-91a0-fe50-a6b7e5dd125b@gmail.com> <20220128182105.GF614@gate.crashing.org> <20220204013156.GD614@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Feb 2022 18:50:55 -0000 On Wed, Feb 16, 2022 at 11:41:37AM -0800, Reshabh K Sharma wrote: > I wanted to add scheduling cost to rd and rs, I was suggested to use > TARGET_SCHED_ADJUST_COST but there I need to check if the instruction is > FLWR and as suggested I tried using get_attr_type. I realized that first I > need to set the type then use get_attr_type. I also couldn't find any other > place to set the attribute other than define_insn but this custom > instruction was just going to be used in inline asm right now so there was > no equivalent rtl from which I can lower into this but since I was not able > to find any other way to set the attribute, I decided to add a pattern > (hoping it to be unmatchable) where I could add the attribute, so inside > riscv.md I added the define_insn for flwr and used set_attr but I'm not > able to find any instruction in the TARGET_SCHED_ADJUST_COST for the > specific type attr. > > 1. Does inline asm compilation flow goes through the > TARGET_SCHED_ADJUST_COST? > 2. Is there a better way to do this? / Am I missing something? GCC does not look at the assembler template to try to figure out what instructions are in there. This is by design. So, the compiler can never know much about how it will schedule on the real machine (it does estimate (pessimistically) how big the resulting machine code will be, so that any branches can reach their target). Making a define_insn for your insn is exactly the right plan. You do not have too hope it does not accidentally match anything else: if you make it an unspec, it can never match anything but itself (nothing with a different "index" number). Segher