From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70137 invoked by alias); 23 Jun 2015 21:35:27 -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 70086 invoked by uid 48); 23 Jun 2015 21:35:24 -0000 From: "ubizjak at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/66626] [i386] gcc.dg/torture/stackalign/non-local-goto-5.c segfaults w/ -mregparm=3 Date: Tue, 23 Jun 2015 21:35: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: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ubizjak at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg02351.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66626 --- Comment #4 from Uro=C5=A1 Bizjak --- (In reply to Uro=C5=A1 Bizjak from comment #3) > The testcase from Comment #1 fails. Got it. LRA miscompiles "f". Function "f" of the testcase from Comment #1 compiles (-O2 -m32 -mregparm= =3D3) to: f.1485: cmpl $2, %eax je .L6 xorl %eax, %eax ret .L6: pushl %esi movl $.L3, %eax pushl %ebp movl %esp, %ebp (32) movl 4(%ebp), %edx (14) movl (%edx), %ebp (33) movl 4(%ebp), %ecx (17) movl 4(%ecx), %esp jmp *%eax In the above asm, (insn 14) clobbers %ebp, which is used as temporary in (i= nsn 32) and (insn 33). In _.ira dump, we have: (insn 3 2 4 2 (set (reg/f:SI 90 [ CHAIN.1 ]) (mem/c:SI (plus:SI (reg/f:SI 16 argp) (const_int -8 [0xfffffffffffffff8])) [3 S4 A8])) t.c:7 90 {*movsi_internal} (expr_list:REG_EQUIV (mem/c:SI (plus:SI (reg/f:SI 16 argp) (const_int -8 [0xfffffffffffffff8])) [3 S4 A8]) (nil))) [...] (insn 14 13 15 3 (set (reg/f:SI 6 bp) (mem:SI (reg/f:SI 90 [ CHAIN.1 ]) [0 S4 A8])) t.c:9 90 {*movsi_internal} (nil)) [...] (insn 17 16 18 3 (set (reg/f:SI 7 sp) (mem:SI (plus:SI (reg/f:SI 90 [ CHAIN.1 ]) (const_int 4 [0x4])) [0 S4 A8])) t.c:9 90 {*movsi_internal} (expr_list:REG_DEAD (reg/f:SI 90 [ CHAIN.1 ]) (nil))) LRA copies (insn 3) just before (insn 14) and (insn 17), eliminating argp on the fly to HARD_FRAME_POINTER (=3D %ebp). Following sequence is generated: (insn 32 13 14 3 (set (reg:SI 1 dx [94]) (mem/c:SI (plus:SI (reg/f:SI 6 bp) (const_int 4 [0x4])) [3 S4 A8])) t.c:9 90 {*movsi_internal} (nil)) (insn 14 32 15 3 (set (reg/f:SI 6 bp) (mem:SI (reg:SI 1 dx [94]) [0 S4 A8])) t.c:9 90 {*movsi_internal} (nil)) [...] (insn 33 16 17 3 (set (reg:SI 2 cx [95]) (mem/c:SI (plus:SI (reg/f:SI 6 bp) (const_int 4 [0x4])) [3 S4 A8])) t.c:9 90 {*movsi_internal} (nil)) (insn 17 33 18 3 (set (reg/f:SI 7 sp) (mem:SI (plus:SI (reg:SI 2 cx [95]) (const_int 4 [0x4])) [0 S4 A8])) t.c:9 90 {*movsi_internal} (nil)) LRA doesn't notice that (insn 14) clobbers propagated argp (=3D %ebp) value= , used in (insn 33). Indeed, fixing the asm to use %edx temporary from (insn 32): .L6: pushl %esi movl $.L3, %eax pushl %ebp movl %esp, %ebp (32) movl 4(%ebp), %edx (14) movl (%edx), %ebp (17) movl 4(%edx), %esp jmp *%eax fixes the testcase. >>From gcc-bugs-return-490020-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 23 21:38:31 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 101598 invoked by alias); 23 Jun 2015 21:38:30 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 101537 invoked by uid 48); 23 Jun 2015 21:38:26 -0000 From: "ubizjak at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/66626] [i4.9/5/6 Regression] gcc.dg/torture/stackalign/non-local-goto-5.c segfaults w/ -mregparm=3 Date: Tue, 23 Jun 2015 21:38: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: 6.0 X-Bugzilla-Keywords: ra X-Bugzilla-Severity: normal X-Bugzilla-Who: ubizjak at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords cf_gcctarget cc component target_milestone short_desc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg02352.txt.bz2 Content-length: 934 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66626 Uro=C5=A1 Bizjak changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ra Target|i?86-*-* |i?86 CC| |vmakarov at gcc dot gnu.org Component|target |rtl-optimization Target Milestone|--- |4.9.4 Summary|[i386] |[i4.9/5/6 Regression] |gcc.dg/torture/stackalign/n |gcc.dg/torture/stackalign/n |on-local-goto-5.c segfaults |on-local-goto-5.c segfaults |w/ -mregparm=3D3 |w/ -mregparm=3D3 --- Comment #5 from Uro=C5=A1 Bizjak --- Reconfirmed as LRA problem. >>From gcc-bugs-return-490021-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 23 22:00:50 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 59660 invoked by alias); 23 Jun 2015 22:00:49 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 59543 invoked by uid 48); 23 Jun 2015 22:00:45 -0000 From: "wilson at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/65932] [5 Regression] Linux-3.10.75 on arm926ej-s does not boot due to wrong code generation Date: Tue, 23 Jun 2015 22:00: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: 5.1.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: critical X-Bugzilla-Who: wilson at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.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: 2015-06/txt/msg02353.txt.bz2 Content-length: 2455 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932 --- Comment #18 from Jim Wilson --- Ultimately, I believe that this is an ARM backend bug. PROMOTE_MODE and TARGET_PROMOTE_FUNCTION_MODE should not behave differently. It would help if the PROMOTE_MODE macro was merged with the TARGET_PROMOTE_FUNCTION_MODE hook, to avoid accidents like this. I've tested my patch to modify PROMOTE_MODE so that it no longer sets UNSIGNEDP for char and short. For the SPEC CPU2000 benchmarks, individual benchmarks are within 1% which is within the noise range, and the full benchmark results have almost identical performance. I get 3 additional failures in the gcc testsuite, for gcc.target/arm/wmul-[123].c. These are testcases to verify generation of the smulbb and smlabb instruction. However, they only work currently because of the extra sign-extends emitted by PROMOTE_MODE. We currently emit an unsigned short load, a sign-extend, and a multiply. The sign-extend gets merged into the multiply. But with the patch, we emit a signed short load and a multiply, and hence can't form smulbb. Unpatched, for wmul-1.c we get ldrh r1, [r4, #2]! ldrh r6, [r0, #2]! smlabb r5, r1, r6, r5 smlabb r2, r1, r1, r2 and patched we get ldrsh r1, [r4, #2]! ldrsh r6, [r0, #2]! mla r5, r1, r6, r5 mla r2, r1, r1, r2 wmul-2.c is similar. There is a bigger difference with wmul-3.c. Unpatched is ldrh r1, [r5, #2]! ldrh r4, [r0, #2]! smulbb r4, r1, r4 subs r6, r6, r4 smulbb r1, r1, r1 subs r2, r2, r1 whereas patched is ldrsh r1, [r4, #2]! ldrsh r6, [r0, #2]! mls r5, r1, r6, r5 mls r2, r1, r1, r2 The patched code is better or equivalent to the unpatched code in all cases, but these testcases no longer serve their purpose. I can fix wmul-1.c by changing types to int and casting to signed short. This doesn't work for wmul-2.c because the scalar sign-extend is moved out of the loop, and no longer available to merge with the multiple. This also doesn't work for wmul-3.c, but only because it is cse'd differently. I get unpatched smulbb r4, r1, r4 subs r6, r6, r4 and patched sxth r4, r4 mls r6, r1, r4, r6 At the moment the only option I have to make wmul-2.c and wmul-3.c work is to remove them