From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8D5D43858C3A; Fri, 23 Jun 2023 19:57:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8D5D43858C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687550236; bh=asfHgTA5hS3+GHrhxdYObahSzY8sCHYd9dmh4IlVdHU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NwoSYnwDpielrWkFa0SmYVUd0FwpFzKI/4BkByhuwbNnsjkK4rGxR9io4ITAGCGCL Bq1OxsV3kN3Inc7EbDeUJu7IJ5gRdpUlSoXwA2Po9x0XUcAja+ngBDH2V+7NNEDCyx F4NrvFEIdms4jKW34ntDU/nkXLNf/L1FVPVu8l8k= From: "bergner at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/109009] Shrink Wrap missed opportunity Date: Fri, 23 Jun 2023 19:57:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: unknown X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: bergner at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jskumari at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109009 --- Comment #9 from Peter Bergner --- (In reply to Surya Kumari Jangala from comment #8) > However, while computing the save/restore cost, we are considering only t= he > memory move cost but not the BB frequency. I think it is important to > consider the frequency too.=20 Yes, you'll need to factor in the BB frequency. Since the save/restore code will go into (at this point modulo shrink-wrapping later) the prologue and epilogue, you'll want something like: * 2 * "ira_memory_move_cost". I think the issue here, is that the "frequency" of the entry block isn't '1= ', but some larger value. I'm not 100% sure, but maybe you can use: REG_FREQ_FROM_BB (ENTRY_BLOCK_PTR_FOR_FN (cfun)) for the BB frequency of the prologue/epilogue? > We factor in the frequency when we compute the > savings on removed copies in allocno_copy_cost_saving(). In this routine,= we > multiply the frequency with ira_register_move_cost. So why not factor in = the > frequency for memory move cost? allocno_copy_cost_saving() is dealing with an actual copy instruction(s), s= o a real instruction in a specific BB, so it knows the frequency of the copy(ie= s).=20 The ira_memory_move_cost is more of a HW cost of a generic load/store and it isn't tied to a specific instruction, so there is no frequency to scale by,= so you'll need to do that manually here.=