2014-10-20 94 views
0

我想用g ++ 4.9.1与NEON数据类型交叉编译一些代码,但我不断崩溃编译器。这种类型的操作是不允许的,还是这是一个编译器问题?我的操作系统是Ubuntu的12.04,而我使用的是ARM-GCC “gcc版本4.9.1(Ubuntu的/ Linaro的4.9.1-10ubuntu2)”与ARM NEON数据类型编译器崩溃

文件名:crash.cpp

#include <arm_neon.h> 

void crash(
    const unsigned short * in, 
    unsigned short * out, 
    const int shift) 
{ 
    for(int x=0; x<200; x+=8) { 
    const uint16x8_t inValue = vld1q_u16(&in[x]); 

    const uint16x8_t normalizedValue = inValue >> shift; 

    vst1q_u16(&out[x], normalizedValue); 
    } 
} 

编译选项:

arm-linux-gnueabihf-g++-4.9 -mfpu=neon-vfpv4 -c crash.cpp -o crash.o 

输出:

crash.cpp: In function ‘void crash(const short unsigned int*, short unsigned int*, int)’: 
crash.cpp:11:51: internal compiler error: in copy_to_mode_reg, at explow.c:654 
    const uint16x8_t normalizedValue = inValue >> shift; 
               ^
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions. 
Preprocessed source stored into /tmp/ccfz4aZr.out file, please attach this to your bugreport. 

此代码编译的罚款,如果我取代 “无符号短” 与 “无符号整型”,在“uint16x8_ t“和”uint32x4_t“,后缀”_u16“后缀为”_u32“后缀。

+0

GCC是否为自然类型提供自动重载操作符?我以为你必须用明确的intrisics(在这种情况下是'vshl')做所有事情。 – Notlikethat 2014-10-20 21:31:51

+0

automagic shift以正常整数工作,虽然它与16位短整数一起崩溃。 – Pete 2014-10-20 21:55:04

+0

您是否在GCC上创建了一个错误报告? – auselen 2014-10-21 08:59:13

回答

2

这是一个编译器错误,你不应该得到一个内部编译器错误。

您应该能够通过使用NEON内部函数进行移位来解决此问题。由于NEON内在函数定义不包括在NEON类型上使用C运算符 - 这是GCC扩展,所以这对其他编译器也更具可移植性。

#include <arm_neon.h> 

void crash(
    const unsigned short * in, 
    unsigned short * out, 
    const int shift) 
{ 
    int16x8_t vshift = vdupq_n_s16(-shift); 
    for(int x=0; x<200; x+=8) { 
    const uint16x8_t inValue = vld1q_u16(&in[x]); 

    const uint16x8_t normalizedValue = vshlq_u16(inValue, vshift); 

    vst1q_u16(&out[x], normalizedValue); 
    } 
}