Bug 43417 - SH: 4.4 ICE in final_scan_insn, at final.c:2604
Summary: SH: 4.4 ICE in final_scan_insn, at final.c:2604
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-03-18 07:15 UTC by Nobuhiro Iwamatsu
Modified: 2010-04-10 11:43 UTC (History)
4 users (show)

See Also:
Host: sh4-linux-gnu
Target: sh4-linux-gnu
Build: sh4-linux-gnu
Known to work: 4.3.4 4.5.0
Known to fail: 4.4.3
Last reconfirmed: 2010-03-20 09:08:58


Attachments
The source code that can reproduce a problem. (15.54 KB, text/x-csrc)
2010-03-18 07:18 UTC, Nobuhiro Iwamatsu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nobuhiro Iwamatsu 2010-03-18 07:15:19 UTC
I found a bug of ICE in gcc-4.4.3 on sh-elf. 
gcc-4.3 and gcc-4.5 does not have this problem.

$ gcc -O2 mtest01-k-e.c
mtest01-k.c: In function �emain�f:
mtest01-k.c:88: error: could not split insn
(jump_insn 312 302 472 mtest01-k.c:64 (parallel [
            (set (pc)
                (if_then_else (leu (reg/v:DI 12 r12 [orig:310 maxbytes ] [310])
                        (const_int 1073741824 [0x40000000]))
                    (label_ref:SI 516)
                    (pc)))
            (clobber (reg:SI 10 r10))
            (clobber (reg:SI 147 t))
        ]) 6 {cbranchdi4_i} (expr_list:REG_BR_PRED (const_int 49 [0x31])
        (expr_list:REG_UNUSED (reg:SI 147 t)
            (expr_list:REG_UNUSED (reg:SI 10 r10)
                (expr_list:REG_BR_PROB (const_int 0 [0x0])
                    (nil))))))
mtest01-k.c:88: internal compiler error: in final_scan_insn, at final.c:2604
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.4/README.Bugs> for instructions.

When I don't optimize it, it doesn't become the error.

$ gcc-4.4 -v 
Using built-in specs.
Target: sh4-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.3-3' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-multilib-list=m4,m4-nofpu --with-cpu=sh4 --enable-checking=release --build=sh4-linux-gnu --host=sh4-linux-gnu --target=sh4-linux-gnu
Thread model: posix
gcc version 4.4.3 (Debian 4.4.3-3)
Comment 1 Nobuhiro Iwamatsu 2010-03-18 07:18:14 UTC
Created attachment 20138 [details]
The source code that can reproduce a problem.

this code generate by -E option.
Sorry. There is the code to reappear, but cannot lower it.
Comment 2 Kazumoto Kojima 2010-03-18 12:39:58 UTC
Looks the same issue in

http://gcc.gnu.org/ml/gcc-patches/2009-04/msg00747.html

though I can't reproduce the problem with my gcc-4.4.3 and
4.4 head compilers for the test case in #1.
Could you try the patch in the above URL?
Comment 3 Nobuhiro Iwamatsu 2010-03-19 06:11:53 UTC
(In reply to comment #2)
> Looks the same issue in
> 
> http://gcc.gnu.org/ml/gcc-patches/2009-04/msg00747.html
> 
> though I can't reproduce the problem with my gcc-4.4.3 and
> 4.4 head compilers for the test case in #1.
> Could you try the patch in the above URL?

I tested this patch. The problem was revised.
gcc-4.4.3 of debian(20,100,226 SVN / r157081 base) revision was not taken in.

Thank you.
Comment 4 Kazumoto Kojima 2010-03-20 09:08:58 UTC
I'm able to reproduce it with -O2 -fno-schedule-insns on 4.4.
Perhaps debian uses the local patch to make -fno-schedule-insns default.
I'll backport the patch referred in #2 to 4.4 branch if it passes
the usual tests on that branch.
Comment 5 Kazumoto Kojima 2010-03-21 22:29:34 UTC
Subject: Bug 43417

Author: kkojima
Date: Sun Mar 21 22:29:19 2010
New Revision: 157610

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157610
Log:
	Backport from mainline:
	2009-05-12  Paolo Bonzini  <bonzini@gnu.org>

	PR target/43417
	* config/sh/sh.md (cbranchdi4_i): Use an "I08" constraint
	instead of "i" constraint.


Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/sh/sh.md

Comment 6 Kazumoto Kojima 2010-03-21 22:32:34 UTC
Fixed.
Comment 7 Jie Zhang 2010-04-10 11:43:51 UTC
For the record, -m4 is needed to reproduce this issue.
Comment 8 Jie Zhang 2010-04-10 15:12:30 UTC
Subject: Bug 43417

Author: jiez
Date: Sat Apr 10 15:12:14 2010
New Revision: 158192

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158192
Log:
	PR target/43417
	* gcc.target/sh/pr43417.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/sh/pr43417.c
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 9 Jie Zhang 2010-04-10 15:14:24 UTC
Subject: Bug 43417

Author: jiez
Date: Sat Apr 10 15:14:13 2010
New Revision: 158193

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158193
Log:
	PR target/43417
	* gcc.target/sh/pr43417.c: New test.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/sh/pr43417.c
Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 10 Jie Zhang 2010-04-10 15:17:27 UTC
Subject: Bug 43417

Author: jiez
Date: Sat Apr 10 15:17:15 2010
New Revision: 158194

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158194
Log:
	PR target/43417
	* gcc.target/sh/pr43417.c: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.target/sh/pr43417.c
Modified:
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog