From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22494 invoked by alias); 18 Jan 2014 17:13:44 -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 22448 invoked by uid 48); 18 Jan 2014 17:13:40 -0000 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/59379] [4.9 Regression] gomp_init_num_threads is compiled into an infinite loop with --with-arch=corei7 --with-cpu=slm Date: Sat, 18 Jan 2014 17:13:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 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: 2014-01/txt/msg01985.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59379 H.J. Lu changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ubizjak at gmail dot com --- Comment #15 from H.J. Lu --- The problem is in ix86_split_lea_for_addr. For LEA operation with SImode_address_operand, which zero-extends SImode to DImode, it turns (set (reg:DI) ...) into (set (reg:SI) ...) We need to do (set (reg:DI) (zero_extend:DI (reg:SI))) at the end: --- diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index ff210c8..5ceccdf 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -18375,7 +18375,7 @@ ix86_split_lea_for_addr (rtx insn, rtx operands[], enum machine_mode mode) ix86_emit_binop (PLUS, mode, target, parts.disp); ix86_emit_binop (PLUS, mode, target, tmp1); - return; + goto check_mode; } ix86_emit_binop (PLUS, mode, target, tmp); @@ -18384,6 +18384,13 @@ ix86_split_lea_for_addr (rtx insn, rtx operands[], enum machine_mode mode) if (parts.disp && parts.disp != const0_rtx) ix86_emit_binop (PLUS, mode, target, parts.disp); } + +check_mode: + if (mode != GET_MODE (operands[0])) + { + gcc_assert (mode == SImode && GET_MODE (operands[0]) == DImode); + emit_insn (gen_zero_extendsidi2 (operands[0], target)); + } } /* Return true if it is ok to optimize an ADD operation to LEA --- Or we can avoid splitting LEA for SImode_address_operand by --- diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 954bbed..e5e6e12 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -5415,10 +5415,11 @@ else return "lea{}\t{%E1, %0|%0, %E1}"; } - "reload_completed && ix86_avoid_lea_for_addr (insn, operands)" + "reload_completed + && !SImode_address_operand (operands[1], VOIDmode) + && ix86_avoid_lea_for_addr (insn, operands)" [(const_int 0)] { - enum machine_mode mode = mode; rtx pat; /* ix86_avoid_lea_for_addr re-recognizes insn and may @@ -5428,12 +5429,7 @@ operands[0] = SET_DEST (pat); operands[1] = SET_SRC (pat); - /* Emit all operations in SImode for zero-extended addresses. Recall - that x86_64 inheretly zero-extends SImode operations to DImode. */ - if (SImode_address_operand (operands[1], VOIDmode)) - mode = SImode; - - ix86_split_lea_for_addr (curr_insn, operands, mode); + ix86_split_lea_for_addr (curr_insn, operands, mode); DONE; } [(set_attr "type" "lea") --- Either patch fixes the problem.