From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27795 invoked by alias); 7 Feb 2013 20:03:07 -0000 Received: (qmail 27417 invoked by uid 48); 7 Feb 2013 20:02:21 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/56195] [4.8 Regression] Error: incorrect register `%rdi' used with `l' suffix (at -O2) Date: Thu, 07 Feb 2013 20:03: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: ra, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.0 X-Bugzilla-Changed-Fields: 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-02/txt/msg00715.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56195 --- Comment #6 from Jakub Jelinek 2013-02-07 20:02:20 UTC --- Actually, that one doesn't really work, because we have pseudo rather than hard reg at that point, which will never simplify. With this: --- lra-constraints.c.jj 2013-02-07 18:34:39.000000000 +0100 +++ lra-constraints.c 2013-02-07 20:58:25.558920536 +0100 @@ -421,8 +421,20 @@ get_reload_reg (enum op_type type, enum if (rtx_equal_p (curr_insn_input_reloads[i].input, original) && in_class_p (curr_insn_input_reloads[i].reg, rclass, &new_class)) { - *result_reg = curr_insn_input_reloads[i].reg; - regno = REGNO (*result_reg); + rtx reg = curr_insn_input_reloads[i].reg; + regno = REGNO (reg); + /* If input is equal to original and both are VOIDmode, + GET_MODE (reg) might be still different from mode. + Ensure we don't return *result_reg with wrong mode. */ + if (GET_MODE (reg) != mode) + { + if (GET_MODE_SIZE (GET_MODE (reg)) < GET_MODE_SIZE (mode)) + continue; + reg = lowpart_subreg (mode, reg, GET_MODE (reg)); + if (reg == NULL_RTX || GET_CODE (reg) != SUBREG) + continue; + } + *result_reg = reg; if (lra_dump_file != NULL) { fprintf (lra_dump_file, " Reuse r%d for reload ", regno); the assembly difference is: - cmpl (%rdi), %rdi + cmpl (%rdi), %edi which is desirable in this case, but not sure if all get_reload_reg callers will grok a SUBREG instead of REG returned in *result_reg.