From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18947 invoked by alias); 17 Mar 2015 10:00:48 -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 18667 invoked by uid 48); 17 Mar 2015 10:00:44 -0000 From: "ubizjak at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/65450] [5.0 Regression]: Unaligned access with -O3 -mtune=k8 Date: Tue, 17 Mar 2015 10:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ubizjak at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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-03/txt/msg01670.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D65450 --- Comment #2 from Uro=C5=A1 Bizjak --- The problematic instruction (insn 1717) is generated from: ;; vect__1095.501_3524 =3D MEM[base: vectp.499_3571, offset: 0B]; (insn 1717 1716 0 (set (reg:V2DF 1511 [ vect__1095.501 ]) (mem:V2DF (reg/f:DI 638 [ vectp.499 ]) [7 MEM[base: vectp.499_3571, offset: 0B]+0 S16 A256])) channel.f90:247 -1 (nil)) >>From gcc-bugs-return-480527-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Mar 17 10:07:34 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 42855 invoked by alias); 17 Mar 2015 10:07:34 -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 42760 invoked by uid 48); 17 Mar 2015 10:07:30 -0000 From: "ktkachov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/65358] wrong parameter passing code with tail call optimization on arm Date: Tue, 17 Mar 2015 10:07: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.6.3 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: critical X-Bugzilla-Who: ktkachov at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg01671.txt.bz2 Content-length: 1133 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65358 --- Comment #14 from ktkachov at gcc dot gnu.org --- Right, I think the root cause is the emit_push_insn in expr.c. It's supposed to push what needs to be pushed from a partial argument onto the stack and do the moves into the registers. Currently it performs the pushes and then does the moves, which does the wrong things if the pushing destroys stack elements that it wants to load into registers. Doing the load-to-registers part first and the pushing second fixed this for me and generated the below: foo: @ args = 16, pretend = 8, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 sub sp, sp, #8 mov r0, r1 mov r1, r2 str lr, [sp, #-4]! ldr lr, [sp, #16] mov ip, sp str r3, [ip, #8]! ldmia ip, {r2, r3} str lr, [sp, #12] ldr lr, [sp], #4 add sp, sp, #8 b bar which still does the tail call optimisation. I haven't tested it more extensively yet, so I'll be taking that approach and prepare and test a patch.