From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9383B3858D28; Tue, 27 Jun 2023 13:18:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9383B3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687871889; bh=b/OmtuOMRn5AcJWWKu8w8+TvVE8zN8pYgZyZK4kmN44=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qtTyybZ/Qio4zzxrJWFNd/E5afpMrjQ+S635ai/pZhCkRKzRYcG800ZXp0PQ9OI1t ts0vNTfEDtK/H8H9akOyg7lfT3pMf6nSF9S8EVYgil64fYhrfgFmFW+KyL9ucNg8T6 LuwY004ZlJyEI6zcZhVXgdyI3iD3XTJRjlbw+2jk= From: "jskumari at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/109009] Shrink Wrap missed opportunity Date: Tue, 27 Jun 2023 13:18:08 +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: jskumari 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 #11 from Surya Kumari Jangala --- (In reply to Peter Bergner from comment #9) > (In reply to Surya Kumari Jangala from comment #8) > > However, while computing the save/restore cost, we are considering only= the > > memory move cost but not the BB frequency. I think it is important to > > consider the frequency too.=20 >=20 > Yes, you'll need to factor in the BB frequency. Since the save/restore c= ode > will go into (at this point modulo shrink-wrapping later) the prologue and > epilogue, you'll want something like: * 2 * > "ira_memory_move_cost". Thanks for confirming that we have to factor in the BB frequency.=20 > 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)) This works. It gives the frequency of the entry block. > for the BB frequency of the prologue/epilogue? >=20 >=20 > > We factor in the frequency when we compute the > > savings on removed copies in allocno_copy_cost_saving(). In this routin= e, we > > multiply the frequency with ira_register_move_cost. So why not factor i= n the > > frequency for memory move cost? >=20 > allocno_copy_cost_saving() is dealing with an actual copy instruction(s),= so > a real instruction in a specific BB, so it knows the frequency of the > copy(ies). 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.=