This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug in builtin_floor optimization


There is some clever code in convert_to_real that converts

double d;
(float)floor(d)

to

floorf((float)d)

(on targets where floor and floorf are considered builtins.)
This is wrong, because the (float)d conversion normally uses
round-to-nearest and can round up to the next integer.  For example:

Attachment: 4221664b.c
Description: Text document



with -O2.
The transformation is also done for ceil, round, rint, trunc and nearbyint.
I'm not a math guru, but it looks like ceil, rint, trunc and nearbyint are
also unsafe for this transformation. round may be salvageable.
Comments? Should I preserve the buggy behavior with -ffast-math?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]