Bug 88331 - [9 Regression] ICE in rtl_verify_bb_layout, at cfgrtl.c:2987
Summary: [9 Regression] ICE in rtl_verify_bb_layout, at cfgrtl.c:2987
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: 9.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-03 18:58 UTC by mateuszb
Modified: 2019-01-09 10:27 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-w64-mingw32
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-01-04 00:00:00


Attachments
pixel.7z (327.91 KB, application/octet-stream)
2018-12-03 20:50 UTC, mateuszb
Details
slicetype.7z (343.18 KB, application/octet-stream)
2018-12-03 21:03 UTC, mateuszb
Details
ii.tar.xz (337.51 KB, application/octet-stream)
2018-12-07 23:51 UTC, mateuszb
Details
preprocessed source (27.54 KB, text/plain)
2019-01-03 10:08 UTC, Rainer Emrich
Details
Somehow reduced testcase (1.38 KB, text/plain)
2019-01-04 11:19 UTC, Uroš Bizjak
Details
gcc9-pr88331.patch (784 bytes, patch)
2019-01-08 16:42 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mateuszb 2018-12-03 18:58:30 UTC
When I compile x265 with option
export CXXFLAGS="-march=core-avx2"
with gcc 9.0 for mingw-w64 target:
g++ -v
Reading specs from f:/msys/m64-900/bin/../lib/gcc/x86_64-w64-mingw32/9.0.0/specs
COLLECT_GCC=f:\msys\m64-900\bin\g++.exe
COLLECT_LTO_WRAPPER=f:/msys/m64-900/bin/../libexec/gcc/x86_64-w64-mingw32/9.0.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: /home/ma/m/source/gcc-9/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-nls --enable-languages=c,c++,objc,obj-c++ --with-gmp=/home/ma/m/build/for_target --with-mpfr=/home/ma/m/build/for_target --with-mpc=/home/ma/m/build/for_target --with-isl=/home/ma/m/build/for_target --enable-twoprocess --disable-libstdcxx-pch --disable-win32-registry --disable-shared --enable-fully-dynamic-string --prefix=/home/ma/m/target --with-sysroot=/home/ma/m/target
Thread model: win32
gcc version 9.0.0 20181203 (experimental) (GCC)

I get errors (it depend of what module x265 compile first):
f:/x265/source/encoder/slicetype.cpp: In member function 'void x265_12bit::Lookahead::cuTree(x265_12bit::Lowres**, int, bool)':
f:/x265/source/encoder/slicetype.cpp:2086:1: error: insn outside basic block
 2086 | }
      | ^
(insn 8402 7720 8403 (parallel [
            (set (reg:DI 5536)
                (plus:DI (reg/f:DI 19 frame)
                    (const_int -6896 [0xffffffffffffe510])))
            (clobber (reg:CC 17 flags))
        ]) 191 {*adddi_1}
     (nil))
during RTL pass: reload
f:/x265/source/encoder/slicetype.cpp:2086:1: internal compiler error: in rtl_verify_bb_layout, at cfgrtl.c:2987
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

*** OR ***

f:/x265/source/common/pixel.cpp: In function 'int {anonymous}::_sa8d_8x8(const pixel*, intptr_t, const pixel*, intptr_t)':
f:/x265/source/common/pixel.cpp:325:1: error: insn outside basic block
  325 | }
      | ^
(insn 270 239 271 (parallel [
            (set (reg:DI 425)
                (plus:DI (reg/f:DI 19 frame)
                    (const_int -304 [0xfffffffffffffed0])))
            (clobber (reg:CC 17 flags))
        ]) -1
     (nil))
during RTL pass: reload
f:/x265/source/common/pixel.cpp:325:1: internal compiler error: in rtl_verify_bb_layout, at cfgrtl.c:2987
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

gcc 9.0 snapshot 20181118 works OK, next snapshots works wrong.
If this error is not reproducible/obvious, I could try to make preprocessed source. Anyway the option "-march=core-avx2" is important for the bug.
Comment 1 Andrew Pinski 2018-12-03 20:21:57 UTC
Can you attach the preprocessed source as requested by https://gcc.gnu.org/bugs/ ?
Comment 2 mateuszb 2018-12-03 20:43:57 UTC
W dniu 03.12.2018 o 21:21, pinskia at gcc dot gnu.org pisze:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88331
> 
> Andrew Pinski <pinskia at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Target|                            |x86_64-w64-mingw32
>           Component|c++                         |target
> 
> --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> Can you attach the preprocessed source as requested by
> https://gcc.gnu.org/bugs/ ?

Big *.ii file attached (bug in pixel.cpp).

Reproduce steps:
$ g++ -c -O3 -march=core-avx2 pixel.ii
f:/x265/source/common/pixel.cpp: In function 'int {anonymous}::_sa8d_8x8(const pixel*, intptr_t, const pixel*, intptr_t)':
f:/x265/source/common/pixel.cpp:325:1: error: insn outside basic block
  325 | }
      | ^
(insn 270 239 271 (parallel [
            (set (reg:DI 425)
                (plus:DI (reg/f:DI 19 frame)
                    (const_int -304 [0xfffffffffffffed0])))
            (clobber (reg:CC 17 flags))
        ]) -1
     (nil))
during RTL pass: reload
f:/x265/source/common/pixel.cpp:325:1: internal compiler error: in rtl_verify_bb_layout, at cfgrtl.c:2987
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 3 mateuszb 2018-12-03 20:50:46 UTC
Created attachment 45148 [details]
pixel.7z

W dniu 03.12.2018 o 21:21, pinskia at gcc dot gnu.org pisze:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88331
> 
> Andrew Pinski <pinskia at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Target|                            |x86_64-w64-mingw32
>           Component|c++                         |target
> 
> --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> Can you attach the preprocessed source as requested by
> https://gcc.gnu.org/bugs/ ?
 
Attachment too big. Second try with 7z archive.
Comment 4 mateuszb 2018-12-03 21:03:35 UTC
Created attachment 45149 [details]
slicetype.7z

W dniu 03.12.2018 o 21:21, pinskia at gcc dot gnu.org pisze:
> --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> Can you attach the preprocessed source as requested by
> https://gcc.gnu.org/bugs/ ?

Now slicetype.ii (in 7z archive). This bug is newer -- probably from r266726
Step to reproduce:
$ g++ -c -O3 -march=core-avx2 slicetype.ii
f:/x265/source/encoder/slicetype.cpp: In member function 'void x265_12bit::Lookahead::cuTree(x265_12bit::Lowres**, int, bool)':
f:/x265/source/encoder/slicetype.cpp:2086:1: error: insn outside basic block
 2086 | }
      | ^
(insn 6071 5573 6072 (parallel [
            (set (reg:DI 4089)
                (plus:DI (reg/f:DI 19 frame)
                    (const_int -6928 [0xffffffffffffe4f0])))
            (clobber (reg:CC 17 flags))
        ]) 191 {*adddi_1}
     (nil))
during RTL pass: reload
f:/x265/source/encoder/slicetype.cpp:2086:1: internal compiler error: in rtl_verify_bb_layout, at cfgrtl.c:2987
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 5 mateuszb 2018-12-07 23:51:53 UTC
Created attachment 45188 [details]
ii.tar.xz

Bug started with r266345
Both files pixel.ii and slicetype.ii could be compile by gcc 9 r266344 and both files ICE gcc 9 r266345.

I've attached xz archive with both *.ii files (maybe it helps).
Comment 6 Rainer Emrich 2019-01-03 09:51:51 UTC
The issue is now shown during bootstrap while building libfortran.

libtool: compile:  /opt/devel/SCRATCH/tmp.Q1UXSYzwJg/gcc-9.0.0/gcc-9.0.0/./gcc/xgcc -B/opt/devel/SCRATCH/tmp.Q1UXSYzwJg/gcc-9.0.0/gcc-9.0.0/./gcc/ -L/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-9.0.0/x86_64-w64-mingw32/lib -L/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-9.0.0/mingw/lib -isystem /opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-9.0.0/x86_64-w64-mingw32/include -isystem /opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-9.0.0/mingw/include -B/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-9.0.0/x86_64-w64-mingw32/bin/ -B/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-9.0.0/x86_64-w64-mingw32/lib/ -isystem /opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-9.0.0/x86_64-w64-mingw32/include -isystem /opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-9.0.0/x86_64-w64-mingw32/sys-include -fchecking=1 -DHAVE_CONFIG_H -I. -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran -iquote../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/io -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/../gcc -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/../gcc/config -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/../libquadmath -I../.././gcc -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/../libgcc -I../libgcc -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/../libbacktrace -I../libbacktrace -I../libbacktrace -std=gnu11 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -Werror=implicit-function-declaration -Werror=vla -fcx-fortran-rules -ffunction-sections -fdata-sections -ffast-math -ftree-vectorize -funroll-loops --param max-unroll-times=4 -g -O2 -MT matmul_i4.lo -MD -MP -MF .deps/matmul_i4.Tpo -c ../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/generated/matmul_i4.c  -DDLL_EXPORT -DPIC -o .libs/matmul_i4.o
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/generated/matmul_i4.c: In function 'matmul_i4_avx2':
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/generated/matmul_i4.c:1210:1: error: insn outside basic block
 1210 | }
      | ^
(insn 10248 8120 10249 (parallel [
            (set (reg:DI 5750)
                (plus:DI (reg/f:DI 19 frame)
                    (const_int -1200 [0xfffffffffffffb50])))
            (clobber (reg:CC 17 flags))
        ]) 191 {*adddi_1}
     (nil))
during RTL pass: reload
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/generated/matmul_i4.c:1210:1: internal compiler error: in rtl_verify_bb_layout, at cfgrtl.c:2987
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
make[3]: *** [Makefile:4194: matmul_i4.lo] Error 1
make[3]: Leaving directory '/opt/devel/SCRATCH/tmp.Q1UXSYzwJg/gcc-9.0.0/gcc-9.0.0/x86_64-w64-mingw32/libgfortran'
Comment 7 Rainer Emrich 2019-01-03 09:59:59 UTC
If I call make within the libgfortran directory I get a slightly different error message:

during RTL pass: postreload
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/generated/matmul_i4.c: In function 'matmul_i4_avx2':
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-9.0.0/libgfortran/generated/matmul_i4.c:1210:1: internal compiler error: in reload_combine_note_use, at postreload.c:1547
 1210 | }
      | ^
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
Comment 8 Rainer Emrich 2019-01-03 10:08:57 UTC
Created attachment 45323 [details]
preprocessed source

I attached the preprocessed source.
Comment 9 Uroš Bizjak 2019-01-04 11:19:09 UTC
Created attachment 45341 [details]
Somehow reduced testcase

The testcase can be compiled with a cross to --target=x86_64-w64-mingw32:

cc1 -O3 -march=core-avx2

ttt.c: In function ‘matmul_i4_avx2’:
ttt.c:139:1: error: insn outside basic block
  139 | }
      | ^
(insn 998 851 999 (parallel [
            (set (reg:DI 764)
                (plus:DI (reg/f:DI 19 frame)
                    (const_int -224 [0xffffffffffffff20])))
            (clobber (reg:CC 17 flags))
        ]) 191 {*adddi_1}
     (nil))
during RTL pass: reload
ttt.c:139:1: internal compiler error: in rtl_verify_bb_layout, at cfgrtl.c:2987
0x6635b6 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
        ../../git/gcc/gcc/rtl-error.c:108
0x8e3621 rtl_verify_bb_layout
        ../../git/gcc/gcc/cfgrtl.c:2987
0x8e3621 rtl_verify_flow_info
        ../../git/gcc/gcc/cfgrtl.c:3033
0x8c784d verify_flow_info()
        ../../git/gcc/gcc/cfghooks.c:263
0x14945c9 checking_verify_flow_info
        ../../git/gcc/gcc/cfghooks.h:198
0x14945c9 try_optimize_cfg
        ../../git/gcc/gcc/cfgcleanup.c:2994
0x14945c9 cleanup_cfg(int)
        ../../git/gcc/gcc/cfgcleanup.c:3159
0xb26ed9 do_reload
        ../../git/gcc/gcc/ira.c:5524
0xb26ed9 execute
        ../../git/gcc/gcc/ira.c:5659
Comment 10 Uroš Bizjak 2019-01-04 11:24:01 UTC
As mentioned in comment #5, this is due to r266345 (AKA fix for PR84877). It looks that the change now emits RTL sequence outside of BB.

This is what can be seen at the end of .reload dump:

...

(code_label 567 566 568 66 8 (nil) [6 uses])
(note 568 567 571 66 [bb 66] NOTE_INSN_BASIC_BLOCK)
(insn 571 568 572 66 (clobber (reg/i:SI 0 ax)) "ttt.c":139:1 -1
     (nil))
(insn 572 571 573 66 (clobber (reg:SI 0 ax [orig:419 <retval> ] [419])) "ttt.c":139:1 -1
     (nil))
(insn 573 572 851 66 (use (reg/i:SI 0 ax)) "ttt.c":139:1 -1
     (nil))
;;  succ:       EXIT [always]  count:1311748 (estimated locally) (FALLTHRU)
;; lr  out 	 0 [ax] 6 [bp] 7 [sp] 16 [argp] 19 [frame]

(note 851 573 998 NOTE_INSN_DELETED)
;; Insn is not within a basic block
(insn 998 851 999 (parallel [
            (set (reg:DI 764)
                (plus:DI (reg/f:DI 19 frame)
                    (const_int -224 [0xffffffffffffff20])))
            (clobber (reg:CC 17 flags))
        ]) 191 {*adddi_1}
     (nil))
;; Insn is not within a basic block
(insn 999 998 1000 (parallel [
            (set (reg:DI 763)
                (plus:DI (reg:DI 764)
                    (const_int 31 [0x1f])))
            (clobber (reg:CC 17 flags))
        ]) 191 {*adddi_1}
     (nil))
;; Insn is not within a basic block
(insn 1000 999 1001 (parallel [
            (set (reg:DI 765)
                (lshiftrt:DI (reg:DI 763)
                    (const_int 5 [0x5])))
            (clobber (reg:CC 17 flags))
        ]) 564 {*lshrdi3_1}
     (expr_list:REG_EQUAL (udiv:DI (reg:DI 763)
            (const_int 32 [0x20]))
        (nil)))
;; Insn is not within a basic block
(insn 1001 1000 0 (parallel [
            (set (reg/f:DI 766)
                (ashift:DI (reg:DI 765)
                    (const_int 5 [0x5])))
            (clobber (reg:CC 17 flags))
        ]) 518 {*ashldi3_1}
     (nil))
Comment 11 Uroš Bizjak 2019-01-04 11:28:43 UTC
Confirmed as gcc-9 Regression, CCs added.
Comment 12 Andrius Burokas 2019-01-07 07:52:09 UTC
While trying to compile GCC trunk (commit cea12873eeeaa7952e315626991b2e162218e134, Thu Dec 27 16:31:50 2018 +0000) on Cygwin (CYGWIN_NT-10.0 LT04LT1279HR2 2.11.2(0.329/5/3) 2018-11-08 14:34 x86_64 Cygwin) got an ICE similar to one reported by Rainer (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88331#c6)

==================================
configure parameters before 'make'
==================================
andbur@LT04LT1279HR2 ~/gcc
$ ./../gcc_source/configure --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp --enable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts --with-cloog-include=/usr/local/include/cloog-isl --enable-lto --enable-checking=release

==========================================
Last few lines where the compilation broke
==========================================
libtool: compile:  /home/andbur/gcc/./gcc/xgcc -B/home/andbur/gcc/./gcc/ -B/usr/local/x86_64-pc-cygwin/bin/ -B/usr/local/x86_64-pc-cygwin/lib/ -isystem /usr/local/x86_64-pc-cygwin/include -isystem /usr/local/x86_64-pc-cygwin/sys-include -fno-checking -DHAVE_CONFIG_H -I. -I../.././../gcc_source/libgfortran -iquote../.././../gcc_source/libgfortran/io -I../.././../gcc_source/libgfortran/../gcc -I../.././../gcc_source/libgfortran/../gcc/config -I../.././../gcc_source/libgfortran/../libquadmath -I../.././gcc -I../.././../gcc_source/libgfortran/../libgcc -I../libgcc -I../.././../gcc_source/libgfortran/../libbacktrace -I../libbacktrace -I../libbacktrace -std=gnu11 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -Werror=implicit-function-declaration -Werror=vla -fcx-fortran-rules -ffunction-sections -fdata-sections -ffast-math -ftree-vectorize -funroll-loops --param max-unroll-times=4 -g -O2 -MT matmul_i4.lo -MD -MP -MF .deps/matmul_i4.Tpo -c ../.././../gcc_source/libgfortran/generated/matmul_i4.c  -DDLL_EXPORT -DPIC -o .libs/matmul_i4.o
during RTL pass: postreload
../.././../gcc_source/libgfortran/generated/matmul_i4.c: In function ‘matmul_i4_avx2’:
../.././../gcc_source/libgfortran/generated/matmul_i4.c:1210:1: internal compiler error: in reload_combine_note_use, at postreload.c:1547
 1210 | }
      | ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
make[3]: *** [Makefile:4194: matmul_i4.lo] Error 1
make[3]: Leaving directory '/home/andbur/gcc/x86_64-pc-cygwin/libgfortran'
make[2]: *** [Makefile:1562: all] Error 2
make[2]: Leaving directory '/home/andbur/gcc/x86_64-pc-cygwin/libgfortran'
make[1]: *** [Makefile:18695: all-target-libgfortran] Error 2
make[1]: Leaving directory '/home/andbur/gcc'
make: *** [Makefile:988: all] Error 2
Comment 13 Jakub Jelinek 2019-01-08 16:42:06 UTC
Created attachment 45381 [details]
gcc9-pr88331.patch

I don't see how that could ever work when assign_stack_local_1 is called from anywhere but the expand pass, one can't emit random code somewhere blindly otherwise (e.g. from the RA).  I think for now it is best to revert to previous behavior when it isn't called during expansion, and if really needed, we can figure out a way for GCC10 how to tell the RA it should emit the alignment itself.
Comment 14 mateuszb 2019-01-08 21:02:22 UTC
The patch from comment #13 solve my problems. Thanks!
Comment 15 Jakub Jelinek 2019-01-09 10:16:41 UTC
Author: jakub
Date: Wed Jan  9 10:16:10 2019
New Revision: 267758

URL: https://gcc.gnu.org/viewcvs?rev=267758&root=gcc&view=rev
Log:
	PR rtl-optimization/88331
	* function.c (assign_stack_local_1): Don't set dynamic_align_addr if
	not currently_expanding_to_rtl.

	* gcc.target/i386/pr88331.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr88331.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/function.c
    trunk/gcc/testsuite/ChangeLog
Comment 16 Jakub Jelinek 2019-01-09 10:27:52 UTC
Fixed.