gcc

ICEs and infinite loops in neon_disambiguate_copy()

Bug #809446 reported by Michael K. Edwards
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Linaro GCC
Fix Released
Medium
Andrew Stubbs
4.6
Fix Released
Medium
Andrew Stubbs
gcc
Fix Released
Medium

Bug Description

neon_disambiguate_copy() fails on some inputs, either with an ICE (mismatched number of register moves) or an infinite loop. Unreduced testcase attached, along with a patch that fixes the ICE, exposing the infinite loop.

Revision history for this message
Michael K. Edwards (m-k-edwards) wrote :
Revision history for this message
Michael K. Edwards (m-k-edwards) wrote :

This patch fixes the ICE, leaving the infinite loop when src and dest are permutations of one another.

Compile test case with -O3 -mfpu=neon. (If you have the fix for 736007, you can add -g as well.)

Before this patch:

make[3]: Entering directory `/home/build/CTBU/MonoLake-foreign/opensource-core/build-trees/libjpeg-turbo/simd'
/bin/bash ../libtool --tag=CC --mode=compile arm-cortex_a9-linux-gcc -DHAVE_CONFIG_H -I. -I.. -I.. -Wall -O3 -mfpu=neon --save-temps -MT jsimd_arm.lo -MD -MP -MF .deps/jsimd_arm.Tpo -c -o jsimd_arm.lo jsimd_arm.c
libtool: compile: arm-cortex_a9-linux-gcc -DHAVE_CONFIG_H -I. -I.. -I.. -Wall -O3 -mfpu=neon --save-temps -MT jsimd_arm.lo -MD -MP -MF .deps/jsimd_arm.Tpo -c jsimd_arm.c -fPIC -DPIC -o .libs/jsimd_arm.o
jsimd_arm.c:526:1: warning: 'parse_proc_cpuinfo' defined but not used [-Wunused-function]
jsimd_arm.c: In function 'jsimd_quantize':
jsimd_arm.c:1334:1: internal compiler error: in neon_disambiguate_copy, at config/arm/arm.c:19841

Revision history for this message
Michael Hope (michaelh1) wrote :

Thank you for the bug report. I've confirmed this with gcc-linaro-4.6-2011.06-0 on ARM:

michaelh@ursa1:~/linaro/bugs$ /tools/toolchains/arch/armv7l/gcc-linaro-4.6-2011.06-0-armv7l-maverick-cbuild130-ursa3-cortexa9r1/bin/gcc -O2 -mfpu=neon -S jsimd_arm.i
jsimd_arm.c: In function 'jsimd_quantize':
jsimd_arm.c:1334:1: internal compiler error: in smallest_mode_for_size, at stor-layout.c:451

The fault occurs at all optimisation levels. There is no known work-around partly as this is NEON specific code. The fault does not occur in gcc-linaro-4.5-2011.06 or gcc trunk r176026.

It fails in a dfferent way in gcc 4.5.3 and gcc 4.6.1:

/tools/toolchains/arch/armv7l/gcc-4.5.3-armv7l-maverick-cbuild121-ursa4-cortexa9r1
jsimd_arm.c: In function 'jsimd_ycc_rgb_convert':
jsimd_arm.c:831:1: error: insn does not satisfy its constraints:
(insn 577 490 578 30 /opt/x-tools/arm-cortex_a9-linux-gnueabi/lib/gcc/arm-cortex_a9-linux-gnueabi/4.6.1/include/arm_neon.h:9670 (set (reg:EI 95 d16 [orig:566 __b ] [566])
        (mem/s/c:EI (pre_dec:SI (reg/f:SI 3 r3 [565])) [11 __b+0 S24 A64])) 730 {*neon_movei} (expr_list:REG_INC (reg/f:SI 3 r3 [565])
        (nil)))
jsimd_arm.c:831:1: internal compiler error: in reload_cse_simplify_operands, at postreload.c:396

This has been fixed in later gcc-linaro releases.

I've set this to medium priority as it is a ftbfs and occurs in NEON specific code.

Changed in gcc-linaro:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Michael Hope (michaelh1) wrote :

The fault seems to be in the splits for EI, CI, OI, and XI size moves. The splitter assumes you can decompose these into a set of TI moves, but that's not always true. Be interesting to work around it by changing the condition from "TARGET_NEON && reload_completed" to ""TARGET_NEON && reload_completed && 0"" and see what happens.

Revision history for this message
Michael Hope (michaelh1) wrote :

Hang on, the fault in the last release is different. This requires the patch for LP: #803232 before it occurs.

Revision history for this message
In , Rmansfield-t (rmansfield-t) wrote :

Created attachment 25347
preprocessed source

$ ./xgcc -v
Using built-in specs.
COLLECT_GCC=./xgcc
Target: arm-unknown-linux-gnueabi
Configured with: ../configure --target=arm-unknown-linux-gnueabi --prefix=/home/ryan/x-tools/arm-unknown-linux-gnueabi --with-sysroot=/home/ryan/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi//sys-root --disable-multilib --with-local-prefix=/home/ryan/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sys-root --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-c99 --enable-long-long --enable-target-optspace target_alias=arm-unknown-linux-gnueabi --enable-languages=c++ --disable-shared --disable-libmudflap --disable-libssp
Thread model: posix
gcc version 4.7.0 20110923 (experimental) [trunk revision 179117] (GCC)

$ ./xgcc -B. -O3 -mfpu=neon -mfloat-abi=softfp ~/ice.i -fpic
/home/ryan/ice.i: In function 'SetupUSEVertexShader':
/home/ryan/ice.i:342:38: warning: incompatible implicit declaration of built-in function 'calloc' [enabled by default]
/home/ryan/ice.i:353:1: internal compiler error: in neon_disambiguate_copy, at config/arm/arm.c:20388
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Revision history for this message
In , Mikpe (mikpe) wrote :

This test case started ICEing on trunk with Ira's r178588:

http://gcc.gnu.org/ml/gcc-cvs/2011-09/msg00199.html

Revision history for this message
Michael Hope (michaelh1) wrote :

Thank you for the bug report. I've confirmed this with gcc-linaro-4.6-2011.09-1 on ARM:

michaelh@ursa1:~/linaro/bugs$ /tools/toolchains/arch/armv7l/gcc-linaro-4.6-2011.09-armv7l-natty-cbuild181-ursa4-cortexa9r1/bin/gcc -c -O3 jsimd_arm.i
jsimd_arm.c: In function 'jsimd_quantize':
jsimd_arm.c:1334:1: internal compiler error: in neon_disambiguate_copy, at config/arm/arm.c:20315

The work-around is to compile at -O1. Which is a bit boring :)

I've set it to medium priority as it is a ftbfs, occurs at high optimisation levels, and the fault exists upstream.

Revision history for this message
In , Ira Rosen (irar) wrote :

Looks like the problem is with neon_movv4si.

My patch enabled the use of quad-word vectors by default, the test doesn't fail with double-words.

Revision history for this message
In , Michael Hope (michaelh1) wrote :

I'm seeing similar at:
 https://bugs.launchpad.net/gcc/+bug/809446

and:
 https://bugs.launchpad.net/gcc-linaro/+bug/885393

but it's a bit random.

Richard Earnshaw was looking at this recently. I'll ping him.

Revision history for this message
In , Rearnsha (rearnsha) wrote :

Has gone latent again on trunk, but confirmed that the code here is both broken and unnecessarily complex. Testing a fix.

Revision history for this message
In , Rearnsha (rearnsha) wrote :

Author: rearnsha
Date: Sat Nov 19 13:47:35 2011
New Revision: 181508

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181508
Log:
PR target/50493
* arm.c (neon_disambiguate_copy): Correctly handle partial overlap
of src and dest operands.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.c

Revision history for this message
In , Rearnsha (rearnsha) wrote :

Author: rearnsha
Date: Sat Nov 19 16:47:02 2011
New Revision: 181510

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181510
Log:
PR target/50493
* arm.c (neon_disambiguate_copy): Correctly handle partial overlap
of src and dest operands.

Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/arm/arm.c

Revision history for this message
In , Rearnsha (rearnsha) wrote :

Fixed on trunk and 4.6 branch

Revision history for this message
Michael Hope (michaelh1) wrote :

Was fixed upstream and in the 4.6 branch. Assigning to Andrew as it will be picked up in the next merge.

Changed in gcc:
importance: Unknown → Medium
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.