Bug 45273 - [11/12/13/14 Regression] The compiler depends on the host double (-fprofile-corection only)
Summary: [11/12/13/14 Regression] The compiler depends on the host double (-fprofile-c...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.5.0
: P2 normal
Target Milestone: 11.5
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks: 45272
  Show dependency treegraph
 
Reported: 2010-08-13 00:54 UTC by Andrew Pinski
Modified: 2023-07-07 10:29 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-01-19 00:00:00


Attachments
Use mpfr in predict.c instead of sreal, and in mcf.c instead of host double (4.77 KB, patch)
2011-03-13 00:32 UTC, Steven Bosscher
Details | Diff
Use mpfr in predict.c instead of sreal, and in mcf.c instead of host double (5.17 KB, patch)
2011-03-13 12:39 UTC, Steven Bosscher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2010-08-13 00:54:59 UTC
While looking into PR 45272, I noticed it depends on the host double which is wrong, we should not depend on that.  The main reason is because different hosts could produce slightly different results depending on the behavior of float.

Oh Second mcf_sqrt depends on IEEE FP single precision.
Comment 1 Steven Bosscher 2010-08-13 07:22:47 UTC
Should use sreal, then?
Comment 2 Jakub Jelinek 2010-08-24 15:42:02 UTC
Well, we don't have sreal_sqrt, and the approximation mcf_sqrt uses is quite tied to the float representation, while it isn't impossible to convert it, I'd say it isn't trivial either.  Perhaps we could use mpfr instead.
Comment 3 Richard Biener 2010-08-30 15:57:37 UTC
I also see SIGFPEs recently on FDO SPEC 2000.
Comment 4 Steven Bosscher 2011-03-13 00:32:06 UTC
Created attachment 23643 [details]
Use mpfr in predict.c instead of sreal, and in mcf.c instead of host double

This completely untested patch shows what I'd like to do: Use mpfr instead of sreal and host double. Comments on the approach welcome.
Comment 5 Steven Bosscher 2011-03-13 10:55:05 UTC
Heh, with my patch (with some further changes) I get failures like this one:
../../trunk/gcc/sel-sched-ir.c:6253:1: error: caller edge frequency 38613 does not match BB frequency 38610

Excess precision? :-)
Comment 6 Steven Bosscher 2011-03-13 12:39:51 UTC
Created attachment 23644 [details]
Use mpfr in predict.c instead of sreal, and in mcf.c instead of host double

Bootstrapped&tested on x86_64-unknown-linux-gnu. Can be queued for GCC 4.7 if the Powers That Be agree this is the right approach.

The mcf.c parts can be posted separately for GCC 4.6 if necessary, but I propose to close this big as WONTFIX for older releases.
Comment 7 Richard Biener 2012-01-20 12:38:42 UTC
OTOH, nowadays all(?) host platforms we support have IEEE enough compliant
HW floating-point (well, details like signed zeros and NaNs/Infs are not
really relevant for GCC) that a hwfloat.h could provide a mapping to
a 32bit / 64bit IEEE float format?

Else the patch certainly looks good to me, but lets queue it for 4.8
(I remembered you posted patches to remove sreal.c, did you?)
Comment 8 stevenb.gcc@gmail.com 2012-01-20 19:17:53 UTC
Is there already a meta bug for patches queued for 4.8?
Comment 9 Jakub Jelinek 2013-03-22 14:43:29 UTC
GCC 4.8.0 is being released, adjusting target milestone.
Comment 10 Jakub Jelinek 2013-05-31 10:58:08 UTC
GCC 4.8.1 has been released.
Comment 11 Jakub Jelinek 2013-10-16 09:48:46 UTC
GCC 4.8.2 has been released.
Comment 12 Richard Biener 2014-05-22 09:02:30 UTC
GCC 4.8.3 is being released, adjusting target milestone.
Comment 13 Jakub Jelinek 2014-12-19 13:32:03 UTC
GCC 4.8.4 has been released.
Comment 14 Richard Biener 2015-06-23 08:14:27 UTC
The gcc-4_8-branch is being closed, re-targeting regressions to 4.9.3.
Comment 15 Jakub Jelinek 2015-06-26 19:56:35 UTC
GCC 4.9.3 has been released.
Comment 16 Richard Biener 2016-08-03 10:48:50 UTC
GCC 4.9 branch is being closed
Comment 17 Jakub Jelinek 2017-10-10 13:25:18 UTC
GCC 5 branch is being closed
Comment 18 Jakub Jelinek 2018-10-26 10:08:12 UTC
GCC 6 branch is being closed
Comment 19 Richard Biener 2019-11-14 07:54:48 UTC
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
Comment 20 Jakub Jelinek 2020-03-04 09:36:26 UTC
GCC 8.4.0 has been released, adjusting target milestone.
Comment 21 Jakub Jelinek 2021-05-14 09:46:14 UTC
GCC 8 branch is being closed.
Comment 22 Richard Biener 2021-06-01 08:04:59 UTC
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Comment 23 Jan Hubicka 2022-01-06 11:52:21 UTC
Note that with the introduction of profile-count.h I chased away most of uses of double for profile calculation. In predict.c we have last occurence when combinindg probabilities from predictors:

          combined_probability = (((double) combined_probability) * probability 
                                  * REG_BR_PROB_BASE / d + 0.5);                

These are still REG_BR_PROB_BASE based (unlike rest of code that uses profile_probability datatype) since that was easier to have in .def file.

Cast to double is there only to get type wide enough for REG_BR_PROB_BASE third power in the 32bit x86 era. It is set to 10000 that is roughly 2^14 so 43 bits (with sign bits) is enough that should be good for all reasonable double implementations. However we could easily change it to int64_t.
Comment 24 Richard Biener 2022-05-27 09:34:12 UTC
GCC 9 branch is being closed
Comment 25 Jakub Jelinek 2022-06-28 10:29:49 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 26 Richard Biener 2023-07-07 10:29:18 UTC
GCC 10 branch is being closed.