From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32686 invoked by alias); 25 Feb 2013 22:22:33 -0000 Received: (qmail 32597 invoked by uid 48); 25 Feb 2013 22:22:11 -0000 From: "steven at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/56446] [4.6/4.7/4.8 Regression] Generate one fewer relocation when calling a checked weakref function Date: Mon, 25 Feb 2013 22:22:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: steven at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Keywords Status Last reconfirmed Summary Ever Confirmed Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2013-02/txt/msg02406.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56446 Steven Bosscher changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|UNCONFIRMED |NEW Last reconfirmed| |2013-02-25 Summary|Generate one fewer |[4.6/4.7/4.8 Regression] |relocation when calling a |Generate one fewer |checked weakref function |relocation when calling a | |checked weakref function Ever Confirmed|0 |1 --- Comment #2 from Steven Bosscher 2013-02-25 22:22:11 UTC --- Slightly modified test case to avoid the relatively new weakref attribute: int f() __attribute__((weak)); /* weakref(("foo")) */ void g() { int (*ptr)() = f; if (ptr) ptr(); } GCC 4.8 r196182 (ignoring cfi stuff) with "-O2 -fPIC": g: cmpq $0, f@GOTPCREL(%rip) je .L1 xorl %eax, %eax jmp f@PLT .L1: ret GCC 4.1.3, GCC 4.4.7 and GCC 4.6.3 produce the same code as above. GCC 3.4.6 with "-O2 -fPIC": g: movq f@GOTPCREL(%rip), %rdx testq %rdx, %rdx je .L1 xorl %eax, %eax movq %rdx, %r11 jmp *%r11 .p2align 4,,7 .L1: rep ; ret Arguably GCC4 produces better code, but GCC 3.4.6 re-uses the address loaded in the register. I think that is the right thing to do, too. So, marking as a regression.