Bug 1502499

Summary: Floating-point changes with -O2 and -fPIC
Product: [Fedora] Fedora Reporter: Elliott Sales de Andrade <quantum.analyst>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: aoliva, davejohansen, fweimer, jakub, jwakely, law, mpolacek
Target Milestone: ---   
Target Release: ---   
Hardware: ppc64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-22 09:54:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Test program none

Description Elliott Sales de Andrade 2017-10-16 06:42:59 UTC
Created attachment 1339039 [details]
Test program

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


Actual results:
On x86_64, all compiled versions return the same results that all match the expected values. On ppc64(le), everything works *except* -O2 -fPIC.


Expected results:
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.

Comment 1 Jakub Jelinek 2017-12-22 09:54:36 UTC
It is FMA, contraction is allowed even without -ffast-math.  You can disable it with -ffp-contract=off.

Comment 2 Elliott Sales de Andrade 2017-12-22 20:17:07 UTC
Yes, that is it! Still curious why it doesn't break except with *both* -O2 and -fPIC.