Bug 1502499 - Floating-point changes with -O2 and -fPIC
Summary: Floating-point changes with -O2 and -fPIC
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 26
Hardware: ppc64
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2017-10-16 06:42 UTC by Elliott Sales de Andrade
Modified: 2017-12-22 20:17 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2017-12-22 09:54:36 UTC
Type: Bug

Attachments (Terms of Use)
Test program (2.01 KB, text/x-csrc)
2017-10-16 06:42 UTC, Elliott Sales de Andrade
no flags Details

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.

Note You need to log in before you can comment on or make changes to this bug.