Created attachment 1339039 [details]
I'm not totally sure if this is a bug, or just something within the expected sphere of differences with floating-point math. It's just a bit surprising how it's triggered to me.
Version-Release number of selected component (if applicable):
Fedora 26 x86_64: g++ (GCC) 7.1.1 20170622 (Red Hat 7.1.1-3)
Fedora 26 ppc64: g++ (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)
Fedora 25 ppc64: g++ (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1)
Steps to Reproduce:
1. Compile and run attached file using g++
2. Compile and run attached file using g++ -fPIC
3. Compile and run attached file using g++ -O2
4. Compile and run attached file using g++ -O2 -fPIC
On x86_64, all compiled versions return the same results that all match the expected values. On ppc64(le), everything works *except* -O2 -fPIC.
I'd have thought everything returns the same results, as happens on x86(_64). At most, I'd have thought an optimization option like -O2 or higher might cause differences. Or maybe -ffast-math, but none of these appear troublesome. It is only -O2 *with* -fPIC that fails.
It is FMA, contraction is allowed even without -ffast-math. You can disable it with -ffp-contract=off.
Yes, that is it! Still curious why it doesn't break except with *both* -O2 and -fPIC.