User account creation filtered due to spam.

Bug 52714 - [4.8 regression] ICE in fixup_reorder_chain, at cfglayout.c:880
Summary: [4.8 regression] ICE in fixup_reorder_chain, at cfglayout.c:880
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.7.0
: P4 normal
Target Milestone: 4.8.5
Assignee: Jeffrey A. Law
Depends on:
Reported: 2012-03-25 15:50 UTC by Dan Horák
Modified: 2015-01-19 22:33 UTC (History)
6 users (show)

See Also:
Target: m68k-linux-gnu
Known to work: 4.9.0
Known to fail: 4.8.1
Last reconfirmed: 2013-12-25 00:00:00

preprocessed source file (18.49 KB, application/octet-stream)
2012-03-25 15:50 UTC, Dan Horák
reduced test case (219 bytes, text/plain)
2012-03-25 22:30 UTC, Mikael Pettersson
preprocessed source, xz compressed (23.94 KB, application/octet-stream)
2012-12-09 18:03 UTC, Thorsten Glaser
revert gcc 4.6 to gcc 4.5 version of PR45695 fix (919 bytes, patch)
2013-01-05 11:57 UTC, Mikael Pettersson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Horák 2012-03-25 15:50:40 UTC
Created attachment 26985 [details]
preprocessed source file

m68k-linux-gnu cross-compiler throws an internal error when compiling the file from attachment with -O1 (-O0 and -O2 are OK), same error exist also 4.6.[23]

[dan@eagle tmp]$ m68k-linux-gnu-gcc -O1 -c regex.i 
../posix/regex.c: In function ‘re_match_2_internal’:
../posix/regex.c:5255:1: internal compiler error: in fixup_reorder_chain, at cfglayout.c:880

[dan@eagle tmp]$ m68k-linux-gnu-gcc -v
Using built-in specs.
Target: m68k-linux-gnu
Configured with: ../gcc-4.7.0-RC-20120302/configure --disable-dependency-tracking --disable-silent-rules --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=m68k-linux-gnu --enable-targets=all --program-prefix=m68k-linux-gnu- --enable-languages=c --without-headers --enable-sjlj-exceptions --with-system-libunwind --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-libquadmath --disable-gold --disable-decimal-float --enable-checking= --enable-gnu-unique-object --enable-linker-build-id --disable-plugin --enable-nls --with-system-zlib --with-bugurl= --enable-obsolete
Thread model: single
gcc version 4.7.0 20120302 (Red Hat 4.7.0-0.11.4) (GCC)
Comment 1 Mikael Pettersson 2012-03-25 17:40:43 UTC
I can reproduce the ICE with gcc 4.8-20120318, 4.7-20120324, and 4.6-20120323, but 4.5-20120315 and 4.4.7 don't ICE.
Comment 2 Mikael Pettersson 2012-03-25 20:49:24 UTC
It's caused by Jakub's r164431:

There are several HAVE_cc0 changes in that patch.
Comment 3 Mikael Pettersson 2012-03-25 22:30:05 UTC
Created attachment 26988 [details]
reduced test case
Comment 4 Thorsten Glaser 2012-12-09 18:03:08 UTC
Created attachment 28910 [details]
preprocessed source, xz compressed

I ran into this as well, native compilation on Debian/m68k:

  CC     src/proxy-bio-unittest.o
gcc -DHAVE_CONFIG_H -I.     -g -O1 -Wall -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -fstack-protector-all -fwrapv -fPIE -Wstack-protector --param=ssp-buffer-size=1 -c -o src/proxy-bio-unittest.o src/proxy-bio-unittest.c
src/proxy-bio-unittest.c: In function 'need_out_bytes':
src/proxy-bio-unittest.c:38:5: warning: stack protector not protecting local variables: variable length buffer [-Wstack-protector]
src/proxy-bio-unittest.c:60:1: internal compiler error: in fixup_reorder_chain, at cfglayout.c:877
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Preprocessed source stored into /tmp/ccqReOfy.out file, please attach this to your bugreport.
make[2]: *** [src/proxy-bio-unittest.o] Error 1

(pbuild3928)root@ara5:/ # gcc -v
Using built-in specs.
Target: m68k-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-14+m68k.2' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libssp --enable-plugin --enable-objc-gc --disable-werror --disable-multilib --enable-checking=release --build=m68k-linux-gnu --host=m68k-linux-gnu --target=m68k-linux-gnu
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-14+m68k.2) 

That’s from building
Comment 5 Mikael Pettersson 2012-12-09 20:22:53 UTC
Thorsten's test case also ICEs gcc-4.7-20121208 and gcc-4.8 r194325.
Comment 6 Mikael Pettersson 2013-01-05 11:57:52 UTC
Created attachment 29086 [details]
revert gcc 4.6 to gcc 4.5 version of PR45695 fix

The ICE is caused by the gcc-4.6 version of the PR45695 fix.  That fix was applied in different form to gcc-4.5, and there it doesn't cause any ICE.  This patch reverts gcc-4.6 to the gcc-4.5 version of the PR45695 fix, which fixes the ICE with gcc-4.6.  Bootstrapped and regression-tested on x86_64, m68k, arm, sparc64, and powerpc64.

I still don't know why the 4.6 version of PR45695 causes the ICE, so I don't intend to submit this patch at this time, but at least it could help other m68k users.
Comment 7 Thorsten Glaser 2013-01-05 14:35:37 UTC
Cool, thanks! I got another one where it fails (centerim) and will test it with this patch, then report back (that should take a few days).
Comment 8 Thorsten Glaser 2013-01-07 23:19:01 UTC
OK, this helped. Wonderful, thanks!
Comment 9 Steven Bosscher 2013-12-24 23:59:02 UTC
So... still a bug here?
Comment 10 Thorsten Glaser 2013-12-25 00:15:38 UTC
Yes, we still run with the code reverted to the 4.5 version in Debian.
Comment 11 Andreas Schwab 2013-12-29 15:56:30 UTC
try_combine is called with

i1 = (insn 14 13 16 2 (set (reg/v/f:SI 34 [ stack ])
        (reg/f:SI 15 %sp)) pr52714.c:9 38 {*movsi_m68k2}
i2 = (insn 16 14 17 2 (set (cc0)
        (compare (reg/v/f:SI 34 [ stack ])
            (const_int 0 [0]))) pr52714.c:10 4 {*tstsi_internal_68020_cf}
i3 = (jump_insn 17 16 18 2 (set (pc)
        (if_then_else (eq (cc0)
                (const_int 0 [0]))
            (label_ref 40)
            (pc))) pr52714.c:10 390 {beq}
     (int_list:REG_BR_PROB 1014 (nil))
 -> 40)

This is then combined into
newpat = (parallel [
        (set (pc)
        (set (reg/v/f:SI 34 [ stack ])
            (reg/f:SI 15 %sp))

This isn't a recognized insn, and it needs to be split.  In the 4.5
version the condition "use_crosses_set_p (SET_SRC (XVECEXP (newpat, 0,
1)), DF_INSN_LUID (i2))" (which returns 1 due to PUSH_ROUNDING) prevents
this from being done, so the whole try fails.

In the post-4.5 version the condition is used to select which of the parts to put first.  The result are the two insn
(insn 16 14 17 2 (set (pc)
        (pc)) pr52714.c:10 2147483647 {NOOP_MOVE}
(jump_insn 17 16 18 2 (set (reg/v/f:SI 34 [ stack ])
        (reg/f:SI 15 %sp)) pr52714.c:10 38 {*movsi_m68k2}
     (int_list:REG_BR_PROB 1014 (nil))
 -> 40)

This is obviously bogus, since the latter is no longer a valid jump_insn.
Comment 12 Jeffrey A. Law 2014-02-06 21:08:22 UTC
So the problem here is try_combine is playing things a bit fast and loose when it rips apart the PARALLEL into two independent sets (one of which is a nop).  In particular it assumes that I3 is an INSN as opposed to a JUMP_INSN or CALL_INSN.  As a result combine is happy to create the bogus RTL as seen in Andreas's last comment.

It's easily fixed and a patch for that is in testing.
Comment 13 Jeffrey A. Law 2014-02-06 21:52:30 UTC
BTW, compiling with -O2 rather than -O1 makes this problem go away.

The problematical sequence (testing that the result of an alloca call is nonzero) is eliminated by the VRP optimizers which only run at -O2 and above.
Comment 14 Jeffrey A. Law 2014-02-27 19:29:11 UTC
Author: law
Date: Thu Feb 27 19:28:40 2014
New Revision: 208204

	PR rtl-optimization/52714
	* combine.c (try_combine): When splitting an unrecognized PARALLEL
	into two independent simple sets, if I3 is a jump, ensure the
	pattern we place into I3 is a (set (pc) ...)

	PR rtl-optimization/52714
	* gcc.c-torture/compile/pr52714.c: New test.

Comment 15 Richard Biener 2014-06-12 13:43:12 UTC
The 4.7 branch is being closed, moving target milestone to 4.8.4.
Comment 16 Segher Boessenkool 2014-12-03 06:01:26 UTC
Author: segher
Date: Wed Dec  3 06:00:54 2014
New Revision: 218302

	PR rtl-optimization/52714
	* combine.c (try_combine): Allow combining two insns into two
	new insns if at least one of those is a noop.

	* New testcase.

Comment 17 Jakub Jelinek 2014-12-19 13:33:10 UTC
GCC 4.8.4 has been released.
Comment 18 Jeffrey A. Law 2015-01-19 22:33:09 UTC
Fixed in 4.9 and on trunk.  Not planning to backport to 4.8.