我正在编译以下ARM NEON内部函数测试代码(在具有Android NDK的Eclipse中):
void foo(uint64_t* Res)
{
uint64_t x = 0xff12aa8902acf78dULL;
uint64x1_t a,b;
a = vld1_u64 (&x);
b = vext_u64 (a, a, 3);
vst1_u64 (Res,b);
}
但我不断收到以下编译器错误:
/home/developer/adt/ndk/ndk-build all
Install : libneon_test.so => libs/armeabi/libneon_test.so
Compile thumb : neon_test <= neon.c
jni/neon.c: In function 'foo':
jni/neon.c:17:1: error: constant out of range
make: *** [obj/local/armeabi-v7a/objs/neon_test/neon.o] Error 1`
第17行是
}
的最后一个foo()
大括号。有谁知道这个奇怪错误的原因是什么?
最佳答案
问题在这条线
b = vext_u64 (a, a, 3);
您不能将
3
作为vext_u64
,it isn't allowed的类次。uint64x1_t vext_u64(uint64x1_t a, uint64x1_t b, __constrange(0,0) int c); // VEXT.64 d0,d0,d0,#0
在这方面, NEON 内在函数的
gcc
的implementation (definition?)看起来不及armcc
的好。了解这种行为的技巧是将
-S
传递给gcc
以将代码转换为程序集,然后尝试编译该程序集文件。这样,gcc会准确地告诉您哪条线出了问题。$ ~/bin/android-ndk-r8d/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=/home/auselen/bin/android-ndk-r8d/platforms/android-14/arch-arm -std=c99 -S neon.c -mfloat-abi=softfp -mfpu=neon -O2
neon.c: In function 'foo':
neon.c:11:1: error: constant out of range
$ ~/bin/android-ndk-r8d/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=/home/auselen/bin/android-ndk-r8d/platforms/android-14/arch-arm -std=c99 -c neon.s -mfloat-abi=softfp -mfpu=neon -O2
neon.s: Assembler messages:
neon.s:28: Error: shift out of range -- `vext.64 d16,d16,d16,#3'