[Bug target/43703] New: Unexpected floating point precision loss due to ARM NEON autovectorization
siarhei dot siamashka at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Apr 9 14:34:00 GMT 2010
Using gcc-4.5.0-RC-20100406.tar.bz2
/************************************************************/
#include <stdio.h>
void __attribute__((noinline)) f(float * __restrict c,
float * __restrict a,
float * __restrict b)
{
int i;
for (i = 0; i < 4; i++) {
c[i] = a[i] * b[i];
}
}
int main()
{
float a[4], b[4], c[4];
a[0] = 1e-40;
b[0] = 1e+38;
f(c, a, b);
printf("c[0]=%f\n", (double)c[0]);
if (c[0] < 0.001)
printf("precision problem: c[0] was flushed to zero\n");
return 0;
}
/************************************************************/
# gcc -mcpu=cortex-a8 -mfloat-abi=softfp -mfpu=neon -O2 -fno-fast-math test.c
# ./a.out
c[0]=0.010000
# gcc -mcpu=cortex-a8 -mfloat-abi=softfp -mfpu=neon -O3 -fno-fast-math test.c
# ./a.out
c[0]=0.000000
precision problem: c[0] was flushed to zero
Using -O3 option turns on autovectorization, and the results of operations
involving denormals get flushed to zero. This happens even if no "-ffast-math"
or any other precision sacrificing options are enabled.
--
Summary: Unexpected floating point precision loss due to ARM NEON
autovectorization
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: siarhei dot siamashka at gmail dot com
GCC build triplet: armv7l-unknown-linux-gnueabi
GCC host triplet: armv7l-unknown-linux-gnueabi
GCC target triplet: armv7l-unknown-linux-gnueabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43703
More information about the Gcc-bugs
mailing list