From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18642 invoked by alias); 6 Jun 2013 22:18:51 -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 18535 invoked by uid 48); 6 Jun 2013 22:18:40 -0000 From: "wmi at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/57459] [4.8/4.9 Regression] LRA inheritance bug Date: Thu, 06 Jun 2013 22:18: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: ra, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: wmi at google dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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-06/txt/msg00317.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57459 --- Comment #6 from wmi at google dot com --- continue the analysis in the first post, for the smallcase 1.c, the IR after calling inherit_in_ebb in lra_inheritance for bb12 is: (insn 289 47 48 12 (set (reg:SI 116 [79]) (reg:SI 121 [79])) 1.c:16 85 {*movsi_internal} (nil)) (insn 48 289 290 12 (set (reg:SI 116 [79]) (if_then_else:SI (eq (reg:CCNO 17 flags) (const_int 0 [0])) (reg:SI 122 [83]) (reg:SI 116 [79]))) 1.c:16 923 {*movsicc_noc} (expr_list:REG_DEAD (reg:SI 122 [83]) (nil))) (insn 290 48 294 12 (set (reg:SI 120 [79]) (reg:SI 116 [79])) 1.c:16 85 {*movsi_internal} (nil)) (insn 294 290 49 12 (set (reg:SI 79) (reg:SI 120 [79])) 1.c:16 85 {*movsi_internal} (nil)) ...... (insn 292 50 51 12 (set (reg:QI 118) (subreg:QI (reg:SI 120 [79]) 0)) 1.c:16 87 {*movqi_internal} (nil)) (insn 51 292 52 12 (parallel [ (set (reg:CC 17 flags) (unspec:CC [ (subreg:QI (reg:SI 79) 0) (reg:QI 118) ] UNSPEC_ADD_CARRY)) (set (subreg:QI (reg:SI 79) 0) (plus:QI (subreg:QI (reg:SI 79) 0)It is still correct (reg:QI 118))) ]) 1.c:16 259 {addqi3_cc} (expr_list:REG_UNUSED (reg:SI 79) (nil))) The IR is still correct after this step. However, after update_ebb_live_info (called after inherit_in_ebb), insn 294 is removed. Then reg 79 cannot get updated value and it doesn't equal to reg 118 anymore. IR is wrong after this step. insn 294 is removed in update_ebb_live_info because the reg type of reg 79 is OP_INOUT but update_ebb_live_info only marks OP_IN type reg as live_regs. So the fix is: Index: gcc/lra-constraints.c =================================================================== --- gcc/lra-constraints.c (revision 199752) +++ gcc/lra-constraints.c (working copy) @@ -4545,7 +4545,7 @@ update_ebb_live_info (rtx head, rtx tail bitmap_clear_bit (&live_regs, reg->regno); /* Mark each used value as live. */ for (reg = curr_id->regs; reg != NULL; reg = reg->next) - if (reg->type == OP_IN + if ((reg->type == OP_IN || reg->type == OP_INOUT) && bitmap_bit_p (&check_only_regs, reg->regno)) bitmap_set_bit (&live_regs, reg->regno); /* It is quite important to remove dead move insns because it Bootstrapped and tested on x86_64-linux.