2014-10-20 44 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); 
    } 
}