public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/64479] New: wrong optimization delayed-branch  for SH
@ 2015-01-03  8:05 oshima-ya@yagoto-urayama.jp
  2015-01-09 11:31 ` [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: oshima-ya@yagoto-urayama.jp @ 2015-01-03  8:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64479

            Bug ID: 64479
           Summary: wrong optimization delayed-branch  for SH
           Product: gcc
           Version: 4.8.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: oshima-ya@yagoto-urayama.jp

On NetBSD/landisk(sh3) 7.0_BETA, gcc4.8.4 generates some strange code.

Test case:

int foo(int);
void bar(int *);
void func(int args)
{
        int key;
        int flag = (args==0);
        bar(&key);
        if (!args) foo(1);
        if (foo(args)) {
                if (flag && key == 0) foo(2);
                else
                    if (flag) foo(3);
        }
}

it generated by compile with -Os -S:

func:
.LFB0:
        .cfi_startproc
        mov.l   r8,@-r15
        .cfi_def_cfa_offset 4
        .cfi_offset 8, -4
        mov.l   r9,@-r15
        .cfi_def_cfa_offset 8
        .cfi_offset 9, -8
        mov.l   r10,@-r15
        .cfi_def_cfa_offset 12
        .cfi_offset 10, -12
        mov.l   r11,@-r15
        .cfi_def_cfa_offset 16
        .cfi_offset 11, -16
        sts.l   pr,@-r15
        .cfi_def_cfa_offset 20
        .cfi_offset 17, -20
        add     #-4,r15
        .cfi_def_cfa_offset 24
        mov.l   .L16,r1
        tst     r4,r4
        movt    r8         # T bit -> R8
        mov     r4,r9
        jsr     @r1        # subroutine call (bar)
        mov     r15,r4
        mov.l   .L18,r11
        bf      .L2     # what condition? (T bit == 0?)
        jsr     @r11
        mov     #1,r4
.L2

When compiled with -Os -fno-delayed-branch -S:

func:
.LFB0:
        .cfi_startproc
        mov.l   r8,@-r15
        .cfi_def_cfa_offset 4
        .cfi_offset 8, -4
        mov.l   r9,@-r15
        .cfi_def_cfa_offset 8
        .cfi_offset 9, -8
        mov.l   r10,@-r15
        .cfi_def_cfa_offset 12
        .cfi_offset 10, -12
        mov.l   r11,@-r15
        .cfi_def_cfa_offset 16
        .cfi_offset 11, -16
        sts.l   pr,@-r15
        .cfi_def_cfa_offset 20
        .cfi_offset 17, -20
        add     #-4,r15
        .cfi_def_cfa_offset 24
        mov.l   .L16,r1
        tst     r4,r4
        movt    r8        # T bit -> R8
        mov     r4,r9
        mov     r15,r4
        jsr     @r1       # subroutine call (bar)
        nop
        tst     r8,r8     # if (R8 == 0) then T bit = 1
        mov.l   .L18,r11  
        bt      .L2       # if (T bit == 1) branch .L2
        mov     #1,r4
        jsr     @r11
        nop
.L2:

With -Os (include -fdelayed-branch), tst r8,r8 instruction is omitted, and
branch condition is inverted.

The same problem in this case occurs in flow_loops_find() function of
gcc/cfgloop.c when building gcc 4.8.4 for NetBSD/sh3-binary. So gcc
native-binary for sh3 will be wrong.
>From gcc-bugs-return-472098-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jan 03 08:19:04 2015
Return-Path: <gcc-bugs-return-472098-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 30993 invoked by alias); 3 Jan 2015 08:19:03 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 30946 invoked by uid 48); 3 Jan 2015 08:18:58 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/64477] [4.9/5 Regression] x86 sse unnecessary GPR spill
Date: Sat, 03 Jan 2015 08:19: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.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub 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: 4.9.3
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc target_milestone short_desc everconfirmed
Message-ID: <bug-64477-4-cebhZhm8wY@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64477-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64477-4@http.gcc.gnu.org/bugzilla/>
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-01/txt/msg00092.txt.bz2
Content-length: 842

https://gcc.gnu.org/bugzilla/show_bug.cgi?idd477

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-01-03
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |vmakarov at gcc dot gnu.org
   Target Milestone|---                         |4.9.3
            Summary|x86 sse unnecessary GPR     |[4.9/5 Regression] x86 sse
                   |spill                       |unnecessary GPR spill
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r210824.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch
  2015-01-03  8:05 [Bug c/64479] New: wrong optimization delayed-branch for SH oshima-ya@yagoto-urayama.jp
@ 2015-01-09 11:31 ` rguenth at gcc dot gnu.org
  2015-01-10  0:38 ` olegendo at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-01-09 11:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64479

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.8.5


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch
  2015-01-03  8:05 [Bug c/64479] New: wrong optimization delayed-branch for SH oshima-ya@yagoto-urayama.jp
  2015-01-09 11:31 ` [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch rguenth at gcc dot gnu.org
@ 2015-01-10  0:38 ` olegendo at gcc dot gnu.org
  2015-01-10  4:31 ` oshima-ya@yagoto-urayama.jp
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-01-10  0:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64479

--- Comment #3 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #2)
>  
> 
> I haven't checked it, but maybe this also helps PR 56451 in some way.
> 

Unfortunately it doesn't.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch
  2015-01-03  8:05 [Bug c/64479] New: wrong optimization delayed-branch for SH oshima-ya@yagoto-urayama.jp
  2015-01-09 11:31 ` [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch rguenth at gcc dot gnu.org
  2015-01-10  0:38 ` olegendo at gcc dot gnu.org
@ 2015-01-10  4:31 ` oshima-ya@yagoto-urayama.jp
  2015-01-13  0:31 ` olegendo at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: oshima-ya@yagoto-urayama.jp @ 2015-01-10  4:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64479

--- Comment #4 from Yasushi Oshima <oshima-ya@yagoto-urayama.jp> ---
> Both patches fix the problem here, but I haven't tested them further.  My
> feeling is that the function reg_set_p should be fixed.

I tried to patch to reg_set_p(), then this problem is fixed.
And the native gcc48 for NetBSD/sh3 works well on the target environment now.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch
  2015-01-03  8:05 [Bug c/64479] New: wrong optimization delayed-branch for SH oshima-ya@yagoto-urayama.jp
                   ` (2 preceding siblings ...)
  2015-01-10  4:31 ` oshima-ya@yagoto-urayama.jp
@ 2015-01-13  0:31 ` olegendo at gcc dot gnu.org
  2015-01-13  1:01 ` olegendo at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-01-13  0:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64479

--- Comment #5 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Author: olegendo
Date: Tue Jan 13 00:30:57 2015
New Revision: 219506

URL: https://gcc.gnu.org/viewcvs?rev=219506&root=gcc&view=rev
Log:
gcc/
    PR target/64479
    * rtlanal.c (set_reg_p): Handle SEQUENCE constructs.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/rtlanal.c


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch
  2015-01-03  8:05 [Bug c/64479] New: wrong optimization delayed-branch for SH oshima-ya@yagoto-urayama.jp
                   ` (3 preceding siblings ...)
  2015-01-13  0:31 ` olegendo at gcc dot gnu.org
@ 2015-01-13  1:01 ` olegendo at gcc dot gnu.org
  2015-01-13  1:19 ` olegendo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-01-13  1:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64479

--- Comment #6 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Author: olegendo
Date: Tue Jan 13 01:01:14 2015
New Revision: 219507

URL: https://gcc.gnu.org/viewcvs?rev=219507&root=gcc&view=rev
Log:
gcc/
    Backport form mainline
    2015-01-13  Oleg Endo  <olegendo@gcc.gnu.org>

    PR target/64479
    * rtlanal.c (set_reg_p): Handle SEQUENCE constructs.

Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/rtlanal.c


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch
  2015-01-03  8:05 [Bug c/64479] New: wrong optimization delayed-branch for SH oshima-ya@yagoto-urayama.jp
                   ` (4 preceding siblings ...)
  2015-01-13  1:01 ` olegendo at gcc dot gnu.org
@ 2015-01-13  1:19 ` olegendo at gcc dot gnu.org
  2015-01-13 22:30 ` olegendo at gcc dot gnu.org
  2015-02-10 20:31 ` olegendo at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-01-13  1:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64479

--- Comment #7 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Author: olegendo
Date: Tue Jan 13 01:18:56 2015
New Revision: 219508

URL: https://gcc.gnu.org/viewcvs?rev=219508&root=gcc&view=rev
Log:
gcc/
    Backport form mainline
    2015-01-13  Oleg Endo  <olegendo@gcc.gnu.org>

    PR target/64479
    * rtlanal.c (set_reg_p): Handle SEQUENCE constructs.

Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/rtlanal.c


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch
  2015-01-03  8:05 [Bug c/64479] New: wrong optimization delayed-branch for SH oshima-ya@yagoto-urayama.jp
                   ` (5 preceding siblings ...)
  2015-01-13  1:19 ` olegendo at gcc dot gnu.org
@ 2015-01-13 22:30 ` olegendo at gcc dot gnu.org
  2015-02-10 20:31 ` olegendo at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-01-13 22:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64479

--- Comment #8 from Oleg Endo <olegendo at gcc dot gnu.org> ---
The issue should be fixed now.  I'd like to keep this PR open for a while
though.  Maybe we can construct a runtime torture test case, although it seems
a bit difficult.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch
  2015-01-03  8:05 [Bug c/64479] New: wrong optimization delayed-branch for SH oshima-ya@yagoto-urayama.jp
                   ` (6 preceding siblings ...)
  2015-01-13 22:30 ` olegendo at gcc dot gnu.org
@ 2015-02-10 20:31 ` olegendo at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-02-10 20:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64479

Oleg Endo <olegendo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #8)
> The issue should be fixed now.  I'd like to keep this PR open for a while
> though.  Maybe we can construct a runtime torture test case, although it
> seems a bit difficult.

I gave up on the test case...


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-02-10 20:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-03  8:05 [Bug c/64479] New: wrong optimization delayed-branch for SH oshima-ya@yagoto-urayama.jp
2015-01-09 11:31 ` [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch rguenth at gcc dot gnu.org
2015-01-10  0:38 ` olegendo at gcc dot gnu.org
2015-01-10  4:31 ` oshima-ya@yagoto-urayama.jp
2015-01-13  0:31 ` olegendo at gcc dot gnu.org
2015-01-13  1:01 ` olegendo at gcc dot gnu.org
2015-01-13  1:19 ` olegendo at gcc dot gnu.org
2015-01-13 22:30 ` olegendo at gcc dot gnu.org
2015-02-10 20:31 ` olegendo at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).