[Bug middle-end/77515] New: GCC fusing of multiply-add ["FMA"] occurring at "-O3" withOUT "-ffast-math" and withOUT "-ffp-contract=fast"
abe_skolnik at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Wed Sep 7 16:57:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77515
Bug ID: 77515
Summary: GCC fusing of multiply-add ["FMA"] occurring at "-O3"
withOUT "-ffast-math" and withOUT "-ffp-contract=fast"
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: abe_skolnik at yahoo dot com
Target Milestone: ---
In GCC, on both x86_64 and AArch64, fusing of multiply-add ["FMA"] is occurring
at "-O3" withOUT "-ffast-math" and withOUT "-ffp-contract=fast". This seems to
be in violation of preservation of exactly the same results as "-O2" and lower
without those "-f<...>" flags, since the fusing may result in higher precision
and therefor different results.
Clang/LLVM without "-f<...>" flags, on both x86_64 and AArch64, only performs
fusing at "-Ofast", not at "-O3".
fma_test.c
----------
double fma(double a, double b, double c) {
return a*b+c;
}
example console log
-------------------
> clang_amd64 -march=haswell -O3 fma_test.c -S -o - | grep -c fmadd
0
> clang_amd64 -march=haswell -O3 fma_test.c -S -o - | egrep -c '(addsd|mulsd)'
2
> clang_amd64 -march=haswell -Ofast fma_test.c -S -o - | grep -c fmadd
1
> clang_amd64 -march=haswell -Ofast fma_test.c -S -o - | egrep -c '(addsd|mulsd)'
0
> clang_aarch64 -O3 fma_test.c -S -o - | grep -c fmadd
0
> clang_aarch64 -O3 fma_test.c -S -o - | egrep -c '(fadd|fmul)'
2
> clang_aarch64 -Ofast fma_test.c -S -o - | grep -c fmadd
1
> clang_aarch64 -Ofast fma_test.c -S -o - | egrep -c '(fadd|fmul)'
0
> gcc_aarch64 -O3 fma_test.c -S -o - | grep -c fmadd
1
> gcc_aarch64 -O3 fma_test.c -S -o - | egrep -c '(fadd|fmul)'
0
> gcc_amd64 -march=haswell -O3 fma_test.c -S -o - | grep -c fmadd
1
> gcc_amd64 -march=haswell -O3 fma_test.c -S -o - | egrep -c '(addsd|mulsd)'
0
More information about the Gcc-bugs
mailing list