From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23496 invoked by alias); 27 May 2011 10:36:27 -0000 Received: (qmail 23399 invoked by uid 22791); 27 May 2011 10:36:26 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_OV X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 May 2011 10:36:11 +0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/49095] Horrible code generation for trivial decrement with test X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status AssignedTo 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 Date: Fri, 27 May 2011 10:50:00 -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 X-SW-Source: 2011-05/txt/msg02653.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49095 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED AssignedTo|unassigned at gcc dot |jakub at gcc dot gnu.org |gnu.org | --- Comment #4 from Jakub Jelinek 2011-05-27 10:35:52 UTC --- Created attachment 24366 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24366 gcc47-pr49095.patch Untested patch which solves this (for some cases) using peephole2. The reason combiner can't do this is that there are no LOG_LINKS in between the comparison and memory store, those two insns are independent and thus don't ever show up together in the same try_combine call (together with their dependencies). And we generate: movq (%rsi), %rax subq $1, %rax testq %rax, %rax movq %rax, (%rsi) je .L4 instead of movq (%rsi), %rax subq $1, %rax movq %rax, (%rsi) je .L4 because in case of multiple uses, LOG_LINKS are on the first use, and the memory store is before the test during combine (only later scheduling changes it). Thus the test has no LOG_LINKS at all and isn't being attempted to be merged together with the subtraction.