From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32295 invoked by alias); 25 Nov 2013 15:43:14 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 32242 invoked by uid 55); 25 Nov 2013 15:43:10 -0000 From: "scovich at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/10474] shrink wrapping for functions Date: Mon, 25 Nov 2013 15:43:00 -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: 3.4.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: scovich at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned 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: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-11/txt/msg02570.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10474 --- Comment #20 from Ryan Johnson --- Hi Martin, (PM reply because I don't have up-to-date information to file a proper bug report with) On 25/11/2013 9:57 AM, jamborm at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10474 > > --- Comment #19 from Martin Jambor --- > (In reply to Ryan Johnson from comment #18) >> Great! Does this mean shrink-wrapping will be in gcc-4.9, at least for >> x86_64 and ppc64? > Well, a fairly basic (but not altogether unreasonable) shrink-wrapping > "was" in gcc 4.8 (and earlier versions) too and that has not changed > at all. The problem with this and similar testcases was that the > register allocator made decisions which made shrink-wrapping > impossible (or at least too difficult to perform). The change I > committed and which will be a part of gcc 4.9 fixes this for a class > of pseudo-registers which commonly result in this problem but other > cases will still remain unresolved, for example PR 51982. For some > statistics about what impact the implemented technique has, see the > email accompanying the first submission of the patch: > http://gcc.gnu.org/ml/gcc-patches/2013-10/msg01719.html > > If you find another similar example which is important and clearly > possible to shrink-wrap but we don't do it, feel free to submit a > new missed-optimization bug and CC me. > One that comes to mind right off, but is from several years ago and possibly no longer true: on platforms like solaris/sparc, accesses to thread-local storage require a function call to retrieve the base of thread-local storage; the compiler seems to emit the call once, in the function prologue. I strongly suspect (but can't confirm, since I no longer have access to Solaris/sparc) that such a function-call-in-prologue would confound subsequent efforts at shrink wrapping. I don't know how often this sort of scenario arises any more, though. It may be that the new emutls stuff has changed everything, because on cygwin and gcc-4.8 I now see separate calls into emutls for every TLS access. As for PR 51982, it looks like having flow-sensitive local analysis could go a long way: just as it can be useful know that an "escaped" pointer has not *yet* escaped (e.g. PR 50346), here it would be useful to know that the stack frame, though perhaps eventually needed, is not needed just yet. Then, generation of the stack frame can be pushed down to the first basic block(s) where the need for a stack frame is undisputed, after any conditions that gate it. But I've been told that teaching gcc to think that way would not be easy... In any case, thanks for the improvement to a hairy problem. Regards, Ryan