This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/71276] New: frndint generation should not depend on flag_unsafe_math_optimizations
- From: "jsm28 at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 25 May 2016 14:02:38 +0000
- Subject: [Bug target/71276] New: frndint generation should not depend on flag_unsafe_math_optimizations
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71276
Bug ID: 71276
Summary: frndint generation should not depend on
flag_unsafe_math_optimizations
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: jsm28 at gcc dot gnu.org
Target Milestone: ---
Target: i?86-*-* x86_64-*-*
When using x87 floating point, the x86 back end supports generating inline code
sequences using the frndint instruction for the rint / ceil / floor / trunc
built-in functions (for SFmode, DFmode and XFmode). But those are conditioned
on flag_unsafe_math_optimizations.
There is no need for them to be conditioned on flag_unsafe_math_optimizations.
For rint, frndint is fully correct. For the others, the only issue is that it
raises "inexact" for non-integer operands, whereas TS 18661-1 specifies that
these functions should not raise "inexact". But:
(a) We don't have any options to select TS 18661-1 requirements, and C99 and
C11 leave it unspecified whether "inexact" is raised, so raising it is OK for
currently supported standards.
(b) Even with TS 18661-1 requirements, it would be OK to use this instruction
if !flag_trapping_math.
(c) The documentation of the .md file patterns for ceil / floor / trunc says
nothing about whether "inexact" is raised or not.
So these inlines should be enabled whenever x87 floating point is in use (maybe
subject to code size considerations; you'd need to check how long the sequences
setting / restoring the rounding mode are compared to a call). And future TS
18661-1 support could disable those for ceil / floor / trunc if flag_ts_18661_1
&& flag_trapping_math.