https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78612
Bug ID: 78612
Summary: Invalid double returned from if statement containing
NEON division
Product: gcc
Version: 4.5.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kudakov at speechpro dot com
Target Milestone: ---
Compile the program with options "-fPIC -O2 -mfpu=neon" for ARM:
#include
typedef double TFLOAT;
TFLOAT GetValue()
{
static const TFLOAT val[6]={0, 200, 300, 400, 500, 600};
static int k = 0;
TFLOAT tmp = val[k];
k = (k+1) % 6;
return tmp;
}
TFLOAT Inv(TFLOAT _d)
{
if (_d - 0.01 > 0)
{
return 1.0f / _d;
}
else
{
return 0.0f;
}
}
int main(int argc, char* argv[])
{
std::cout << Inv(GetValue()) << std::endl;
std::cout << Inv(GetValue()) << std::endl;
std::cout << Inv(GetValue()) << std::endl;
std::cout << Inv(GetValue()) << std::endl;
return 0;
}
Output is:
0
inf
inf
inf
Must be:
0
0.005
0.0033
0.0025
If you use float for TFLOAT or use "-mfpu=vfpv3" results will be valid.
About used g++:
arm-cortexa9-linux-gnueabi-g++ -v
Using built-in specs.
COLLECT_GCC=arm-cortexa9-linux-gnueabi-g++
COLLECT_LTO_WRAPPER=/home/OSELAS.Toolchain-2011.02.0/arm-cortexa9-linux-gnueabi/gcc-linaro-4.5-2011.02
-0-glibc-2.13-binutils-2.21-kernel-2.6.36-sanitized/bin/../libexec/gcc/arm-cortexa9-linux-gnueabi/4.5.
2/lto-wrapper
Target: arm-cortexa9-linux-gnueabi
Configured with:
/home/adam/Downloads/OSELAS.Toolchain-2011.02.0/platform-arm-cortexa9-linux-gnueabi-g
cc-linaro-4.5-2011.02-0-glibc-2.13-binutils-2.21-kernel-2.6.36-sanitized/build-cross/gcc-linaro-4.5-20
11.02-0/configure --target=arm-cortexa9-linux-gnueabi
--with-sysroot=/opt/OSELAS.Toolchain-2011.02.0/a
rm-cortexa9-linux-gnueabi/gcc-linaro-4.5-2011.02-0-glibc-2.13-binutils-2.21-kernel-2.6.36-sanitized/sy
sroot-arm-cortexa9-linux-gnueabi --disable-multilib --with-float=softfp
--with-fpu=neon --with-cpu=cor
tex-a9 --enable-__cxa_atexit --disable-sjlj-exceptions --disable-nls
--disable-decimal-float --disable
-fixed-point --disable-win32-registry --enable-symvers=gnu
--with-pkgversion=OSELAS.Toolchain-2011.02.
0 --with-system-zlib
--with-gmp=/home/adam/Downloads/OSELAS.Toolchain-2011.02.0/platform-arm-cortexa9-
linux-gnueabi-gcc-linaro-4.5-2011.02-0-glibc-2.13-binutils-2.21-kernel-2.6.36-sanitized/sysroot-host
-
-with-mpfr=/home/adam/Downloads/OSELAS.Toolchain-2011.02.0/platform-arm-cortexa9-linux-gnueabi-gcc-lin
aro-4.5-2011.02-0-glibc-2.13-binutils-2.21-kernel-2.6.36-sanitized/sysroot-host
--prefix=/opt/OSELAS.T
oolchain-2011.02.0/arm-cortexa9-linux-gnueabi/gcc-linaro-4.5-2011.02-0-glibc-2.13-binutils-2.21-kernel
-2.6.36-sanitized --enable-languages=c,c++ --enable-threads=posix --enable-c99
--enable-long-long --en
able-libstdcxx-debug --enable-profile --enable-shared --disable-libssp
--enable-checking=release
Thread model: posix
gcc version 4.5.2 (OSELAS.Toolchain-2011.02.0)