Bug 51882 - ICE: in extract_insn, at recog.c:2109 (unrecognizable insn) when building Mesa on ARM
Summary: ICE: in extract_insn, at recog.c:2109 (unrecognizable insn) when building Mes...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-17 13:58 UTC by Thierry Reding
Modified: 2012-02-19 17:48 UTC (History)
2 users (show)

See Also:
Host:
Target: arm-unknown-linux-gnueabi
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-01-21 00:00:00


Attachments
Preprocessed source. (88.26 KB, application/octet-stream)
2012-01-17 13:58 UTC, Thierry Reding
Details
reduced testcase (919 bytes, text/x-csrc)
2012-01-21 12:29 UTC, Ramana Radhakrishnan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry Reding 2012-01-17 13:58:50 UTC
Created attachment 26351 [details]
Preprocessed source.

I can reproduce this ICE reliably by running the following commands in a
git checkout of Mesa (git://anongit.freedesktop.org/mesa/mesa.git):

  $ cd src/mesa
  $ ${CROSS_COMPILE}gcc -c -o swrast/s_span.o swrast/s_span.c -DFEATURE_GL=1 -DFEATURE_ES1=1 -DFEATURE_ES2=1 -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN -DUSE_XCB -DUSE_XSHM -DHAVE_MINCORE -DHAVE_LIBUDEV -I../../include -I../../src/glsl -I../../src/mesa -I../../src/mapi -I../../src/gallium/include -I../../src/gallium/auxiliary -mlittle-endian -mapcs -mabi=aapcs-linux -mno-thumb-interwork -g -O2 -marm -march=armv7-a -mtune=cortex-a9 -Uarm -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wall -Wextra -Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing -fno-builtin-memcmp -fPIC -fvisibility=hidden -save-temps -v

Where the CROSS_COMPILE variable points to the ARM cross-compiler. I've tested
with a variety of versions and can reproduce this with the CodeSourcery
2009q3 (gcc 4.4.1), 2010q1 (gcc 4.4.1), 2010.09 (gcc 4.5.1), 2011.03 (gcc 4.5.2)
and 2011.09 (gcc 4.6.1) toolchains as well as with a custom toolchain based on
gcc 4.6.2 and gcc-4.6-20120113. However, the issue is no longer present in the
latest 4.7 snapshot (tested with a custom toolchain based on gcc-4.7-20120114).
I was also not able to reproduce the ICE with an older CodeSourcery toolchain
(2009q1, gcc 4.3.3).

The attached preprocessed source file is from the custom gcc-4.6-20120113
toolchain, with the following output when running the above command:

---

Using built-in specs.
COLLECT_GCC=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/bin/arm-unknown-linux-gnueabi-gcc-4.6.3
COLLECT_LTO_WRAPPER=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.6.3/lto-wrapper
Target: arm-unknown-linux-gnueabi
Configured with: ../configure --target=arm-unknown-linux-gnueabi --prefix=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr --datadir=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/share --infodir=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/share/info --mandir=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/share/man --libdir=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/lib --libexecdir=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/lib --includedir=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/sys-root/usr/include --with-gxx-include-dir=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/sys-root/usr/include/c++/4.6.3 --with-pkgversion='PBS 2010.08-wip' --program-prefix=arm-unknown-linux-gnueabi- --with-mpfr=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr --with-gmp=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr --enable-languages=c,c++,objc,obj-c++ --disable-libssp --with-as=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/bin/arm-unknown-linux-gnueabi-as --with-ld=/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/bin/arm-unknown-linux-gnueabi-ld --with-sysroot=yes
Thread model: posix
gcc version 4.6.3 20120113 (prerelease) (PBS 2010.08-wip) 
COLLECT_GCC_OPTIONS='-c' '-o' 'swrast/s_span.o' '-D' 'FEATURE_GL=1' '-D' 'FEATURE_ES1=1' '-D' 'FEATURE_ES2=1' '-D' '_GNU_SOURCE' '-D' 'PTHREADS' '-D' 'HAVE_POSIX_MEMALIGN' '-D' 'USE_XCB' '-D' 'USE_XSHM' '-D' 'HAVE_MINCORE' '-D' 'HAVE_LIBUDEV' '-I' '../../include' '-I' '../../src/glsl' '-I' '../../src/mesa' '-I' '../../src/mapi' '-I' '../../src/gallium/include' '-I' '../../src/gallium/auxiliary' '-mlittle-endian' '-mapcs' '-mabi=aapcs-linux' '-mno-thumb-interwork' '-g' '-O2' '-marm' '-march=armv7-a' '-mtune=cortex-a9' '-U' 'arm' '-mfpu=vfpv3-d16' '-mfloat-abi=softfp' '-Wall' '-Wextra' '-Wmissing-prototypes' '-std=c99' '-ffast-math' '-fno-strict-aliasing' '-fno-builtin-memcmp' '-fPIC' '-fvisibility=hidden' '-save-temps' '-v'
 /home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.6.3/cc1 -E -quiet -v -I ../../include -I ../../src/glsl -I ../../src/mesa -I ../../src/mapi -I ../../src/gallium/include -I ../../src/gallium/auxiliary -D FEATURE_GL=1 -D FEATURE_ES1=1 -D FEATURE_ES2=1 -D _GNU_SOURCE -D PTHREADS -D HAVE_POSIX_MEMALIGN -D USE_XCB -D USE_XSHM -D HAVE_MINCORE -D HAVE_LIBUDEV -U arm swrast/s_span.c -mlittle-endian -mapcs -mabi=aapcs-linux -mno-thumb-interwork -marm -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 -mfloat-abi=softfp -std=c99 -Wall -Wextra -Wmissing-prototypes -ffast-math -fno-strict-aliasing -fno-builtin-memcmp -fPIC -fvisibility=hidden -g -fworking-directory -O2 -fpch-preprocess -o s_span.i
ignoring nonexistent directory "/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/sys-root/usr/local/include"
ignoring nonexistent directory "/home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.6.3/../../../../../arm-unknown-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
 ../../include
 ../../src/glsl
 ../../src/mesa
 ../../src/mapi
 ../../src/gallium/include
 ../../src/gallium/auxiliary
 /home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.6.3/include
 /home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.6.3/include-fixed
 /home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/sys-root/usr/include
End of search list.
COLLECT_GCC_OPTIONS='-c' '-o' 'swrast/s_span.o' '-D' 'FEATURE_GL=1' '-D' 'FEATURE_ES1=1' '-D' 'FEATURE_ES2=1' '-D' '_GNU_SOURCE' '-D' 'PTHREADS' '-D' 'HAVE_POSIX_MEMALIGN' '-D' 'USE_XCB' '-D' 'USE_XSHM' '-D' 'HAVE_MINCORE' '-D' 'HAVE_LIBUDEV' '-I' '../../include' '-I' '../../src/glsl' '-I' '../../src/mesa' '-I' '../../src/mapi' '-I' '../../src/gallium/include' '-I' '../../src/gallium/auxiliary' '-mlittle-endian' '-mapcs' '-mabi=aapcs-linux' '-mno-thumb-interwork' '-g' '-O2' '-marm' '-march=armv7-a' '-mtune=cortex-a9' '-U' 'arm' '-mfpu=vfpv3-d16' '-mfloat-abi=softfp' '-Wall' '-Wextra' '-Wmissing-prototypes' '-std=c99' '-ffast-math' '-fno-strict-aliasing' '-fno-builtin-memcmp' '-fPIC' '-fvisibility=hidden' '-save-temps' '-v'
 /home/thierry.reding/src/pbs-experimental.git/toolchains/arm-unknown-linux-gnueabi/usr/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.6.3/cc1 -fpreprocessed s_span.i -quiet -dumpbase s_span.c -mlittle-endian -mapcs -mabi=aapcs-linux -mno-thumb-interwork -marm -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 -mfloat-abi=softfp -auxbase-strip swrast/s_span.o -g -O2 -Wall -Wextra -Wmissing-prototypes -std=c99 -version -ffast-math -fno-strict-aliasing -fno-builtin-memcmp -fPIC -fvisibility=hidden -o s_span.s
GNU C (PBS 2010.08-wip) version 4.6.3 20120113 (prerelease) (arm-unknown-linux-gnueabi)
        compiled by GNU C version 4.6.2 20111223 (prerelease), GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (PBS 2010.08-wip) version 4.6.3 20120113 (prerelease) (arm-unknown-linux-gnueabi)
        compiled by GNU C version 4.6.2 20111223 (prerelease), GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 7fad8c4e675218b56e8d9c2b6af7198f
swrast/s_span.c: In function ‘_swrast_write_rgba_span’:
swrast/s_span.c:1304:1: error: unrecognizable insn:
(insn 5607 5606 5608 280 (set (reg:HI 1 r1)
        (reg:SI 69 s6)) swrast/s_span.c:891 -1
     (nil))
swrast/s_span.c:1304:1: internal compiler error: in extract_insn, at recog.c:2109
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

---

I haven't been able to reduce this into a small test-case unfortunately.
However I was able to bisect the issue to the following commit in Mesa:
3d7c5a4f6f4155e249f6eac76d861eb1bc59eb69. I'm not sure if that helps,
though.

I have also played around with various compiler options. The ICE goes
away if I use -O1 instead of -O2. It also goes away if I change
-mfloat-abi=softfp to -mfloat-abi=soft. If I change -mtune=cortex-a9 to
-mtune=cortex-a8, it also compiles fine.

I'd be happy to provide more information if needed.
Comment 1 Ramana Radhakrishnan 2012-01-21 12:29:02 UTC
Created attachment 26403 [details]
reduced testcase

Reduced testcase. 

Configured with : 


--target=arm-linux-gnueabi --with-cpu=cortex-a9 --with-fpu=neon --with-float=softfp -

Command line options. : 

 ./xgcc -B`pwd` -S -O2  -fPIC   -mapcs -O2  -Wall    -ffast-math -mtune=cortex-a9 besttry.c 

Ramana
Comment 2 Thierry Reding 2012-01-23 07:24:14 UTC
> Configured with : 
> 
> --target=arm-linux-gnueabi --with-cpu=cortex-a9 --with-fpu=neon
> --with-float=softfp -
> 
> Command line options. : 
> 
>  ./xgcc -B`pwd` -S -O2  -fPIC   -mapcs -O2  -Wall    -ffast-math
> -mtune=cortex-a9 besttry.c 

Hi Ramana,

I can confirm that your reduced testcase triggers the ICE on the
cross-compiler that I use, although I need to add the following
command-line options:

  -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp

I guess you get these implicitly because of the different options
that you passed at configuration.

Thanks for looking at this.
Thierry
Comment 3 Mikael Pettersson 2012-02-19 11:17:20 UTC
(In reply to comment #0)
> However, the issue is no longer present in the
> latest 4.7 snapshot (tested with a custom toolchain based on gcc-4.7-20120114).

Using Ramana's reduced test case I still get the ICE with gcc-4.7-20120218.
Comment 4 Steven Bosscher 2012-02-19 16:06:11 UTC
This bug happens in reload...
Comment 5 Steven Bosscher 2012-02-19 17:48:16 UTC
With slightly modified test case (manually inlined apply_aa_coverage()):

BEFORE RELOAD:

(insn 142 133 314 9 (set (subreg:SI (reg:HI 283) 0)
        (unsigned_fix:SI (fix:SF (reg/v:SF 226 [ a ])))) besttry.c:73 682 {fixuns_truncsfsi2}
     (expr_list:REG_DEAD (reg/v:SF 226 [ a ])
        (nil)))


Reloads for insn # 142
Reload 0: reload_in (SI) = (plus:SI (reg/f:SI 11 fp)
                                                    (const_int -65536 [0xffffffffffff0000]))
        CORE_REGS, RELOAD_FOR_OUTPUT_ADDRESS (opnum = 0)
        reload_in_reg: (plus:SI (reg/f:SI 11 fp)
                                                    (const_int -65536 [0xffffffffffff0000]))
        reload_reg_rtx: (reg:SI 12 ip)
Reload 1: GENERAL_REGS, RELOAD_FOR_OUTPUT_ADDRESS (opnum = 0), can't combine, secondary_reload_p
        reload_reg_rtx: (reg:DI 8 r8)
Reload 2: GENERAL_REGS, RELOAD_FOR_OUTPUT_ADDRESS (opnum = 0), can't combine, secondary_reload_p
        reload_reg_rtx: (reg:SI 10 sl)
        secondary_out_reload = 1

        secondary_out_icode = reload_outhi
Reload 3: reload_out (SI) = (subreg:SI (mem/c:HI (plus:SI (plus:SI (reg/f:SI 11 fp)
                                                                (const_int -65536 [0xffffffffffff0000]))
                                                            (const_int -52 [0xffffffffffffffcc])) [14 %sfp+-65544 S2 A64]) 0)
        VFP_LO_REGS, RELOAD_FOR_OUTPUT (opnum = 0)
        reload_out_reg: (subreg:SI (reg:HI 283) 0)
        reload_reg_rtx: (reg:SI 77 s14)
        secondary_out_reload = 2



AFTER RELOAD:

(insn 142 133 355 9 (set (reg:SI 77 s14)
        (unsigned_fix:SI (fix:SF (reg/v:SF 78 s15 [orig:226 a ] [226])))) besttry.c:73 682 {fixuns_truncsfsi2}
     (nil))

(insn 355 142 356 9 (set (reg:SI 12 ip)
        (plus:SI (reg/f:SI 11 fp)
            (const_int -65536 [0xffffffffffff0000]))) besttry.c:73 4 {*arm_addsi3}
     (nil))

(insn 356 355 357 9 (set (reg:HI 10 sl)
        (reg:SI 77 s14)) besttry.c:73 -1
     (nil))

(insn 357 356 358 9 (set (mem:QI (plus:SI (reg:SI 12 ip)
                (const_int -52 [0xffffffffffffffcc])) [0 S1 A8])
        (reg:QI 10 sl)) besttry.c:73 -1
     (nil))

(insn 358 357 359 9 (set (reg:SI 8 r8)
        (lshiftrt:SI (subreg:SI (reg:HI 10 sl) 0)
            (const_int 8 [0x8]))) besttry.c:73 -1
     (nil))

(insn 359 358 314 9 (set (mem:QI (plus:SI (reg:SI 12 ip)
                (const_int -51 [0xffffffffffffffcd])) [0 S1 A8])
        (reg:QI 8 r8)) besttry.c:73 -1
     (nil))

besttry.c: In function ‘_swrast_write_rgba_span’:
besttry.c:108:1: error: unrecognizable insn:
(insn 356 355 357 9 (set (reg:HI 10 sl)
        (reg:SI 77 s14)) besttry.c:73 -1
     (nil))
besttry.c:108:1: internal compiler error: in extract_insn, at recog.c:2123


Looks like a secondary reload failed.