[Bug target/106440] on Mac M1 chip undefined behavior of double arithmetic

yaobig97 at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jul 25 22:59:28 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106440

--- Comment #3 from Yuhao Yao <yaobig97 at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> ubuntu@ubuntu:~/src/upstream-gcc-aarch64\# g++ t55.cc -ffp-contract=on -O2
> ubuntu@ubuntu:~/src/upstream-gcc-aarch64\# ./a.out
> 3e+09 3e+09
> 0
> 0
> ubuntu@ubuntu:~/src/upstream-gcc-aarch64\# g++ t55.cc -ffp-contract=fast -O2
> ubuntu@ubuntu:~/src/upstream-gcc-aarch64\# ./a.out
> 3e+09 3e+09
> 512
> 0
> 
> 
> GCC defaults to "-ffp-contract=fast" which enables the use of the Fused
> multiple add instruction in some cases. 
> 
> What is happening in this case is the second print is being constant folded
> (before the FMA instruction is formed) and the first print uses a fnmsub
> instruction.
> 
> That is there is no bug, you just don't understand floating point.

Ah thanks! It seems that I know too few things on floating point and I should
have done more research before making this post. Sorry for wasting your time.


More information about the Gcc-bugs mailing list