From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25231 invoked by alias); 5 Oct 2013 22:17:37 -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 25186 invoked by uid 48); 5 Oct 2013 22:17:33 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/58517] icvt (after combine) puts ccreg clobbering insn between ccset insn and ccreg use Date: Sat, 05 Oct 2013 22:17: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: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: olegendo 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-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: 2013-10/txt/msg00308.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58517 Oleg Endo changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |steven at gcc dot gnu.org --- Comment #3 from Oleg Endo --- The problematic transformation happens in ifcvt.c (noce_try_cmove_arith). I've only briefly looked over that code and can think of the following options how to fix the issue: 1) Check whether insn_a and insn_b modify the src reg (ccreg) of the conditional branch. If they do, don't do the transformation. On SH, the resulting code would be the same as not specifying -mpretend-cmove: cmp/ge r5,r4 mov r6,r0 bf/s .L6 sub r4,r0 rts nop .L6: sett mov r5,r0 rts subc r4,r0 2) Check whether insn_a and insn_b modify the src reg (ccreg) of the conditional branch. If they do, try to move the insn that sets the ccreg before the conditional branch, _after_ the emitted insn_a and insn_b and right before the conditional move. On SH, the resulting code would look something like this: sett mov r5,r0 sub r4,r6 subc r4,r0 cmp/ge r5,r4 bf 0f mov r6,r0 0: rts nop Steven, since you're RTL optimizers reviewer, could you please provide some feedback regarding the matter?