glibc/sysdeps/x86_64/fpu
Joseph Myers 30dcf959d2 Avoid "inexact" exceptions in i386/x86_64 trunc functions (bug 15479).
As discussed in
<https://sourceware.org/ml/libc-alpha/2016-05/msg00577.html>, TS
18661-1 disallows ceil, floor, round and trunc functions from raising
the "inexact" exception, in accordance with general IEEE 754 semantics
for when that exception is raised.  Fixing this for x87 floating point
is more complicated than for the other versions of these functions,
because they use the frndint instruction that raises "inexact" and
this can only be avoided by saving and restoring the whole
floating-point environment.

As I noted in
<https://sourceware.org/ml/libc-alpha/2016-06/msg00128.html>, I have
now implemented a GCC option -fno-fp-int-builtin-inexact for GCC 7,
such that GCC will inline these functions on x86, without caring about
"inexact", when the default -ffp-int-builtin-inexact is in effect.
This allows users to get optimized code depending on the options they
pass to the compiler, while making the out-of-line functions follow TS
18661-1 semantics and avoid "inexact".

This patch duly fixes the out-of-line trunc function implementations
to avoid "inexact", in the same way as the nearbyint implementations.

I do not know how the performance of implementations such as these
based on saving the environment and changing the rounding mode
temporarily compares to that of the C versions or SSE 4.1 versions (of
course, for 32-bit x86 SSE implementations still need to get the
return value in an x87 register); it's entirely possible other
implementations could be faster in some cases.

Tested for x86_64 and x86.

	[BZ #15479]
	* sysdeps/i386/fpu/s_trunc.S (__trunc): Save and restore
	floating-point environment rather than just control word.
	* sysdeps/i386/fpu/s_truncf.S (__truncf): Likewise.
	* sysdeps/i386/fpu/s_truncl.S (__truncl): Save and restore
	floating-point environment, with "invalid" exceptions merged in,
	rather than just control word.
	* sysdeps/x86_64/fpu/s_truncl.S (__truncl): Likewise.
	* math/libm-test.inc (trunc_test_data): Do not allow spurious
	"inexact" exceptions.
2016-06-27 17:26:52 +00:00
..
multiarch Do not raise "inexact" from x86_64 SSE4.1 ceil, floor (bug 15479). 2016-05-24 21:11:18 +00:00
dla.h Remove x86_64 __GNUC_PREREQ (4, 6) conditional. 2014-11-14 18:53:07 +00:00
e_acosl.c
e_atan2l.c
e_exp2l.S Refactor x86_64 libm code forcing underflow exceptions. 2015-09-24 22:25:30 +00:00
e_exp10l.S
e_expf.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
e_expl.S Fix i386/x86_64 expl, exp10l, expm1l for sNaN input (bug 20226). 2016-06-08 21:55:06 +00:00
e_fmodl.S
e_ilogbl.S
e_log2l.S Fix i386/x86_64 log2l (sNaN) (bug 20235). 2016-06-09 18:04:30 +00:00
e_log10l.S Fix i386/x86_64 log10l (sNaN) (bug 20228). 2016-06-08 22:59:18 +00:00
e_logl.S Fix i386/x86_64 logl (sNaN) (bug 20227). 2016-06-08 22:24:06 +00:00
e_powl.S Fix x86_64 / x86 powl inaccuracy for integer exponents (bug 19848). 2016-03-24 01:32:52 +00:00
e_remainderl.S
e_scalbl.S Fix i386/x86_64 scalbl with sNaN input (bug 20296). 2016-06-23 22:17:41 +00:00
e_sqrt.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
e_sqrtf.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
e_sqrtl.c
fclrexcpt.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
fedisblxcpt.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
feenablxcpt.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
fegetenv.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
fegetexcept.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
fegetround.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
feholdexcpt.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
fesetenv.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
fesetround.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
feupdateenv.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
fgetexcptflg.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
fraiseexcpt.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
fsetexcptflg.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
ftestexcept.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Implies
k_rem_pio2l.c
libm-test-ulps Fix x86_64 / x86 powl inaccuracy for integer exponents (bug 19848). 2016-03-24 01:32:52 +00:00
Makefile Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
math_ldbl.h
math_private.h Use movq for 64-bit operations 2013-05-15 20:33:45 +02:00
math-tests-arch.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
printf_fphex.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_atanl.c
s_ceill.S Avoid "inexact" exceptions in i386/x86_64 ceil functions (bug 15479). 2016-06-27 17:24:30 +00:00
s_copysign.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_copysignf.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_copysignl.S
s_cosf.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_expm1l.S
s_fabs.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_fabsf.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_fabsl.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_finitel.S
s_floorl.S Avoid "inexact" exceptions in i386/x86_64 floor functions (bug 15479). 2016-06-27 17:25:47 +00:00
s_fmax.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_fmaxf.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_fmaxl.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_fmin.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_fminf.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_fminl.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_fpclassifyl.c
s_isinfl.c
s_isnanl.c
s_llrint.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_llrintf.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_llrintl.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_log1pl.S Fix i386/x86_64 log1pl (sNaN) (bug 20229). 2016-06-08 23:11:42 +00:00
s_logbl.c
s_lrint.S
s_lrintf.S
s_lrintl.S
s_nearbyintl.S Simplify x86 nearbyint functions. 2016-06-22 15:40:30 +00:00
s_nextafterl.c
s_nexttoward.c
s_nexttowardf.c
s_rintl.c
s_scalbnl.S Make scalbn set errno (bug 6803). 2015-09-16 21:11:00 +00:00
s_signbit.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_signbitf.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_significandl.c
s_sincosf.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_sinf.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
s_truncl.S Avoid "inexact" exceptions in i386/x86_64 trunc functions (bug 15479). 2016-06-27 17:26:52 +00:00
svml_d_cos2_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_cos4_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_cos4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_cos8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_exp2_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_exp4_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_exp4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_exp8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_exp_data.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_exp_data.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_log2_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_log4_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_log4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_log8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_log_data.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_log_data.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_pow2_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_pow4_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_pow4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_pow8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_pow_data.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_pow_data.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_sin2_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_sin4_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_sin4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_sin8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_sincos2_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_sincos4_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_sincos4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_sincos8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_trig_data.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_trig_data.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_d_wrapper_impl.h Use JUMPTARGET in x86-64 mathvec 2016-03-16 14:24:19 -07:00
svml_finite_alias.S Use PIC relocation in ALIAS_IMPL 2016-02-17 14:23:32 -08:00
svml_s_cosf4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_cosf8_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_cosf8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_cosf16_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_expf4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_expf8_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_expf8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_expf16_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_expf_data.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_expf_data.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_logf4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_logf8_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_logf8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_logf16_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_logf_data.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_logf_data.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_powf4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_powf8_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_powf8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_powf16_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_powf_data.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_powf_data.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_sincosf4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_sincosf8_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_sincosf8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_sincosf16_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_sinf4_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_sinf8_core_avx.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_sinf8_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_sinf16_core.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_trig_data.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_trig_data.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
svml_s_wrapper_impl.h Use JUMPTARGET in x86-64 mathvec 2016-03-16 14:24:19 -07:00
test-double-libmvec-alias-avx2-main.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias-avx2-mod.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias-avx2.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias-avx512-main.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias-avx512-mod.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias-avx512.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias-avx-main.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias-avx-mod.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias-avx.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias-main.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias-mod.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-libmvec-alias.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-double-vlen2-wrappers.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-double-vlen2.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-double-vlen4-avx2-wrappers.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-double-vlen4-avx2.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-double-vlen4-wrappers.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-double-vlen4.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-double-vlen8-wrappers.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-double-vlen8.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-float-libmvec-alias-avx2-main.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias-avx2-mod.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias-avx2.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias-avx512-main.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias-avx512-mod.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias-avx512.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias-avx-main.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias-avx-mod.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias-avx.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias-main.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias-mod.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-libmvec-alias.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
test-float-vlen4-wrappers.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-float-vlen4.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-float-vlen8-avx2-wrappers.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-float-vlen8-avx2.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-float-vlen8-wrappers.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-float-vlen8.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-float-vlen16-wrappers.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-float-vlen16.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
test-libmvec-alias-mod.c Added tests to ensure linkage through libmvec *_finite aliases which are 2016-06-20 21:15:50 +03:00
Versions Vector sincosf for x86_64 and tests. 2015-06-18 20:11:27 +03:00
x86_64-math-asm.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00