ICE in constprop.2 (ARM NEON related?)

Bug #936863 reported by pmeerw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GCC
Fix Released
Medium
Andrew Stubbs
Linaro GCC Tracking
Invalid
Undecided
Unassigned

Bug Description

$ arm-linux-gnueabi-gcc -c -O2 -mfloat-abi=softfp -mfpu=neon -c ice.c
ice.c: In function ‘remap_stereo_to_mono_neon.constprop.2’:
ice.c:25:1: internal compiler error: Segmentation fault
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/ccGuDaQn.out file, please attach this to your bugreport.

$ arm-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabi/4.6.1/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-7ubuntu2~ppa3' --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/arm-linux-gnueabi/include/c++/4.6.1 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv7-a --with-float=softfp --with-fpu=vfpv3-d16 --with-mode=thumb --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include --with-headers=/usr/arm-linux-gnueabi/include --with-libs=/usr/arm-linux-gnueabi/lib
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-7ubuntu2~ppa3)

#include "arm_neon.h"

static void remap_stereo_to_mono_neon(int m, void *dst, unsigned n) {
    unsigned i;

    switch (m) {
        case 0:
        {
            float *d = (float *) dst;

            for (i = 0; i < n/4; i++) {
                float32x4_t mono;
                vst1q_f32(d, mono);
            }
            break;
        }
        case 1:
        {
            for (i = 0; i < n/8; i++) {
            }
            break;
        }
    }
}

#define SAMPLES 1019

int main() {
    float mono[SAMPLES];
    remap_stereo_to_mono_neon(0, mono, SAMPLES);
    remap_stereo_to_mono_neon(1, mono, SAMPLES);
    return 0;
}

Revision history for this message
pmeerw (pmeerw) wrote :
Revision history for this message
pmeerw (pmeerw) wrote :

also occurs with Linaro GCC 4.6-2012.02

Revision history for this message
Andrew Stubbs (ams-codesourcery) wrote :

Upstream 4.7 does not ICE, but compiles remap_stereo_to_mono_neon away to a no-op with the options given. I recommend testing this with "-fno-inline".

Revision history for this message
Andrew Stubbs (ams-codesourcery) wrote :

The SEGFAULT occurs in arm_print_operand as it tries to write out the final assembler code for remap_stereo_to_mono_neon.

The instruction is:

(insn:TI 15 50 18 4 (set (mem/s:V4SF (reg/v/f:SI 1 r1 [orig:138 dst ] [138]) [0 *(void[16] *) dst_2(D)+0 A8])
        (unspec:V4SF [
                (reg/v:V4SF 95 d16 [orig:135 mono ] [135])
            ] 179)) <path>/arm_neon.h:8316 1578 {neon_vst1v4sf}
     (expr_list:REG_DEAD (reg/v:V4SF 95 d16 [orig:135 mono ] [135])
        (nil)))

The failure is in trying to get the "MEM_SIZE" for "(mem/s:V4SF (reg/v/f:SI 1 r1))" - MEM_SIZE returns an unexpected null-pointer.

Revision history for this message
pmeerw (pmeerw) wrote :

my current workaround (with 4.6) is move the code in the case blocks to separate functions and prohibit inlining of those functions

is there a convenient way to test linaro 4.7?

a fix for 4.6 would be appreciated...

Revision history for this message
Ulrich Weigand (uweigand) wrote :

The memory size is not always known. In 4.6, MEM_SIZE returned an rtx, which was either a CONST_INT rtx, or NULL to indicate unknown memory size. In 4.7, the accessor macros were rewritten, and MEM_SIZE now always returns a HOST_WIDE_INT directly; to indicate the case of unknown memory size, there is now an extra macro MEM_SIZE_KNOWN_P (if this returns true, MEM_SIZE will always return 0).

The code in config/arm/arm.c:arm_print_operand for the 'A' output modifier neglects to check for the case of unknown memory size. In 4.7, this happens to be harmless, since unknown memory size will cause MEM_SIZE to return 0, which cases arm_print_operand to simply fall through to its default case and not output any alignment hint. However, in 4.6, this scenario causes a crash due to dereferencing the NULL MEM_SIZE rtx.

This code ought to be fixed to explicity check for unknown memory size (via MEM_SIZE_KNOWN_P in 4.7 / MEM_SIZE == NULL in 4.6), and omit alignment hints in that case.

A separate question might be why memory size is unknown here. The weird "void[16]" type might have something to do with that ...

Revision history for this message
Andrew Stubbs (ams-codesourcery) wrote :

This patch seems to fix the problem.

Revision history for this message
Andrew Stubbs (ams-codesourcery) wrote :

The patch has now been proposed for merging.

Changed in gcc-linaro:
assignee: nobody → Andrew Stubbs (ams-codesourcery)
Changed in gcc-linaro:
status: New → In Progress
Revision history for this message
Andrew Stubbs (ams-codesourcery) wrote :

This revision does not need to be pushed upstream.

Related: lp:gcc-linaro/4.6,revno=106870

Changed in gcc-linaro:
milestone: none → 4.6-2012.03
status: In Progress → Fix Committed
Changed in gcc-linaro-tracking:
milestone: none → target-specific
status: New → Invalid
Michael Hope (michaelh1)
Changed in gcc-linaro:
importance: Undecided → Medium
Michael Hope (michaelh1)
Changed in gcc-linaro:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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