From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30407 invoked by alias); 12 Mar 2013 23:15:12 -0000 Received: (qmail 28570 invoked by uid 48); 12 Mar 2013 23:14:40 -0000 From: "steven at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/56605] Redundant branch introduced during loop2 phases Date: Tue, 12 Mar 2013 23:15: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-Keywords: missed-optimization X-Bugzilla-Severity: normal 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: CC 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-03/txt/msg00993.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56605 Steven Bosscher changed: What |Removed |Added ---------------------------------------------------------------------------- CC|steven at gcc dot gnu.org | --- Comment #3 from Steven Bosscher 2013-03-12 23:14:39 UTC --- GCC gets to implies_p with: Breakpoint 11, implies_p (a=0x3fffb5fd1410, b=0x3fffb5fd15c0) at ../../trunk/gcc/loop-iv.c:1499 1499 if (GET_CODE (a) == EQ) (gdb) p debug_rtx(a) (eq:SI (subreg:SI (reg:DI 153 [ bnd.10D.2035+-4 ]) 4) (const_int 0 [0])) $26 = void (gdb) p debug_rtx(b) (eq:SI (subreg:SI (reg:DI 153 [ bnd.10D.2035+-4 ]) 4) (const_int 0 [0])) $27 = void (gdb) But implies_p doesn't handle SUBREGs. If it would allow REGs and SUBREGs of REGs, it would fold the assumption away: 1504 if (REG_P (op0)) (gdb) p op0 $29 = (rtx) 0x3fffb5fd13e0 (gdb) p debug_rtx(op0) (subreg:SI (reg:DI 153 [ bnd.10D.2035+-4 ]) 4) $30 = void (gdb) p debug_rtx(op1) (const_int 0 [0]) $31 = void (gdb) p debug_rtx(simplify_replace_rtx (b, op0, op1)) (const_int 1 [0x1]) $32 = void Something like the following, perhaps? Index: loop-iv.c =================================================================== --- loop-iv.c (revision 196575) +++ loop-iv.c (working copy) @@ -1496,19 +1496,26 @@ implies_p (rtx a, rtx b) rtx op0, op1, opb0, opb1, r; enum machine_mode mode; + if (rtx_equal_p (a, b)) + return true; + if (GET_CODE (a) == EQ) { op0 = XEXP (a, 0); op1 = XEXP (a, 1); - if (REG_P (op0)) + if (REG_P (op0) + || (GET_CODE (op0) == SUBREG + && REG_P (SUBREG_REG (op0)))) { r = simplify_replace_rtx (b, op0, op1); if (r == const_true_rtx) return true; } - if (REG_P (op1)) + if (REG_P (op1) + || (GET_CODE (op1) == SUBREG + && REG_P (SUBREG_REG (op1)))) { r = simplify_replace_rtx (b, op1, op0); if (r == const_true_rtx)