From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7942 invoked by alias); 26 Mar 2014 21:14:31 -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 7902 invoked by uid 48); 26 Mar 2014 21:14:26 -0000 From: "timo.kreuzer at reactos dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/39284] Computed gotos combined too aggressively Date: Wed, 26 Mar 2014 21:14:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.4.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: timo.kreuzer at reactos dot 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-Flags: X-Bugzilla-Changed-Fields: cc 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: 2014-03/txt/msg02474.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39284 Timo Kreuzer changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |timo.kreuzer at reactos dot org --- Comment #12 from Timo Kreuzer --- Any updates on this (after 5 years)? Or any workarounds? I tried to do some optimization to my x86 instruction parser code by using computed gotos. This post (https://blogs.oracle.com/nike/entry/fast_interpreter_using_gcc_s) suggests that it should give good speed improvements and the shown compilation results looked promising. But the results with newer GCC versions were so bad, I went back to a simple switch() The 2 major speed improvements (less instructions / improved branch prediction) are completely killed by this bug. Another thing, that I find suspicious (maybe this is some crazy optimization I just don't understand) is that GCC doesn't generate a single JMP with a memory operand anymore, but first loads the memory into a register and then does a register based JMP, even when the load operation is exactly the same in all cases. >>From the comments it looks like there is already a working patch. Why is it not committed? I'd really appreaciate if you could fix this asap. PS: It would be great if you could make this work for switch statements in a loop as well! Normally people don't hassle with computed gotos, they use a switch. If this is in a loop and cases go back directly to the switch statement, the additional jump should be eliminated, possibly duplicating n instructions from the top of the loop before the switch.