From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1393 invoked by alias); 4 Jul 2012 10:11:18 -0000 Received: (qmail 1382 invoked by uid 22791); 4 Jul 2012 10:11:17 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED,TW_ZJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Jul 2012 10:11:04 +0000 From: "ubizjak at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/53433] [4.8 Regression] ICE in int_mode_for_mode, at stor-layout.c:424 during lto-bootstrap Date: Wed, 04 Jul 2012 10:11:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ubizjak at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 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: 2012-07/txt/msg00429.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53433 --- Comment #21 from Uros Bizjak 2012-07-04 10:10:13 UTC --- It looks that expand_builtin_strncmp gets miscompiled. Try to compile the testcase from Comment #5 with -O2 on x86_64-pc-linux-gnu. Put breakpoint in gen_cmpstrnsi. When debugging "normal", non-LTO, non-profiled build, we get: Breakpoint 1, gen_cmpstrnsi (operand0=0x7ffff1ace8a0, operand1=0x7ffff1acb8b8, operand2=0x7ffff1acb918, operand3=0x7ffff19a84f0, operand4=0x7ffff19a8480) at ../../gcc-svn/trunk/gcc/config/i386/i386.md:15989 15989 (set (match_operand:P 0 "register_operand" "=D") (gdb) bt #0 gen_cmpstrnsi (operand0=0x7ffff1ace8a0, operand1=0x7ffff1acb8b8, operand2=0x7ffff1acb918, operand3=0x7ffff19a84f0, operand4=0x7ffff19a8480) at ../../gcc-svn/trunk/gcc/config/i386/i386.md:15989 #1 0x00000000005bb0c0 in expand_builtin_strncmp (exp=0x7ffff1acdd20, target=0x7ffff1ace8a0, mode=) at ../../gcc-svn/trunk/gcc/builtins.c:4000 (gdb) up #1 0x00000000005bb0c0 in expand_builtin_strncmp (exp=0x7ffff1acdd20, target=0x7ffff1ace8a0, mode=) at ../../gcc-svn/trunk/gcc/builtins.c:4000 4000 GEN_INT (MIN (arg1_align, arg2_align))); (gdb) li 3995 3996 arg1_rtx = get_memory_rtx (arg1, len); 3997 arg2_rtx = get_memory_rtx (arg2, len); 3998 arg3_rtx = expand_normal (len); 3999 insn = gen_cmpstrnsi (result, arg1_rtx, arg2_rtx, arg3_rtx, 4000 GEN_INT (MIN (arg1_align, arg2_align))); 4001 if (insn) 4002 { 4003 emit_insn (insn); 4004 (gdb) p target $11 = (rtx_def *) 0x7ffff1ace8a0 (gdb) p result $12 = (rtx_def *) 0x7ffff1ace8a0 (gdb) debugging profiledbootstrap (--with-build-config=bootstrap-lto): Breakpoint 3, gen_cmpstrnsi (operand0=0x7ffff1ace9e0, operand1=0x7ffff1acb8b8, operand2=0x7ffff1acb918, operand3=0x7ffff19a84f0, operand4=0x7ffff19a8480) at ../../gcc-svn/trunk/gcc/config/i386/i386.md:15989 15989 (set (match_operand:P 0 "register_operand" "=D") (gdb) bt #0 gen_cmpstrnsi (operand0=0x7ffff1ace9e0, operand1=0x7ffff1acb8b8, operand2=0x7ffff1acb918, operand3=0x7ffff19a84f0, operand4=0x7ffff19a8480) at ../../gcc-svn/trunk/gcc/config/i386/i386.md:15989 #1 0x0000000000b3310f in _ZL22expand_builtin_strncmpP9tree_nodeP7rtx_def12machine_mode.isra.13 ( target=0x7ffff1ace8a0, exp=0x7ffff1acdd20) at ../../gcc-svn/trunk/gcc/builtins.c:4000 (gdb) p target $12 = (struct rtx_def *) 0x7ffff1ace8a0 (gdb) p result $13 = '\000' (gdb) The trick is that a couple of lines above, we have: /* Make a place to write the result of the instruction. */ result = target; if (! (result != 0 && REG_P (result) && GET_MODE (result) == insn_mode && REGNO (result) >= FIRST_PSEUDO_REGISTER)) result = gen_reg_rtx (insn_mode); Probably "result" doesn't get propagated correctly to gen_cmpstrnsi, we have: (gdb) p *target $15 = {code = REG, mode = SImode, jump = 0, call = 0, unchanging = 0, volatil = 0, in_struct = 0, (gdb) down #0 gen_cmpstrnsi (operand0=0x7ffff1ace9e0, operand1=0x7ffff1acb8b8, operand2=0x7ffff1acb918, operand3=0x7ffff19a84f0, operand4=0x7ffff19a8480) at ../../gcc-svn/trunk/gcc/config/i386/i386.md:15989 15989 (set (match_operand:P 0 "register_operand" "=D") (gdb) p *operand0 $14 = {code = REG, mode = VOIDmode, jump = 0, call = 0, unchanging = 0, volatil = 0, in_struct = 0, Everything goes downhill there. (sorry for not using debug_rtx here, calling it gdb says "Cannot resolve function debug_rtx to any overloaded instance".)