diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-04-25 02:19:04 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-04-25 02:19:04 +0200 |
commit | 018730326d878d98b85b1256ff220e76665ed97e (patch) | |
tree | 39976b0fbb3c7afa4583d54d0be78c63ec5ff351 /gcc/d/intrinsics.cc | |
parent | 873878bb82443ce738f35b1ad3c9ef98f6aeb6da (diff) | |
download | gcc-018730326d878d98b85b1256ff220e76665ed97e.tar.gz |
d: Merge upstream dmd 09db0c41e, druntime e68a5ae3.
* New core.math.toPrec templates have been added as an intrinsic.
Some floating point algorithms, such as Kahan-Babuska-Neumaier
Summation, require rounding to specific precisions. Rounding to
precision after every operation, however, loses overall precision in
the general case and is a runtime performance problem.
Adding these functions guarantee the rounding at required points in
the code, and document where in the algorithm the requirement exists.
* Support IBM long double types in core.internal.convert.
* Add missing aliases for 64-bit vectors in core.simd.
* RUNNABLE_PHOBOS_TEST directive has been properly integrated into the
D2 language testsuite.
Reviewed-on: https://github.com/dlang/druntime/pull/3063
https://github.com/dlang/dmd/pull/11054
gcc/d/ChangeLog:
* intrinsics.cc (expand_intrinsic_toprec): New function.
(maybe_expand_intrinsic): Handle toPrec intrinsics.
* intrinsics.def (TOPRECF, TOPREC, TOPRECL): Add toPrec intrinsics.
Diffstat (limited to 'gcc/d/intrinsics.cc')
-rw-r--r-- | gcc/d/intrinsics.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/d/intrinsics.cc b/gcc/d/intrinsics.cc index 9a9fd41727f..c7bde88e5cd 100644 --- a/gcc/d/intrinsics.cc +++ b/gcc/d/intrinsics.cc @@ -467,6 +467,25 @@ expand_intrinsic_pow (tree callexp) base, exponent); } +/* Expand a front-end intrinsic call to toPrec(). This takes one argument, the + signature to which can be either: + + T toPrec(T)(float f); + T toPrec(T)(double f); + T toPrec(T)(real f); + + This rounds the argument F to the precision of the specified floating + point type T. The original call expression is held in CALLEXP. */ + +static tree +expand_intrinsic_toprec (tree callexp) +{ + tree f = CALL_EXPR_ARG (callexp, 0); + tree type = TREE_TYPE (callexp); + + return convert (type, f); +} + /* Expand a front-end intrinsic call to va_arg(). This takes either one or two arguments, the signature to which can be either: @@ -818,6 +837,9 @@ maybe_expand_intrinsic (tree callexp) CALL_EXPR_ARG (callexp, 1), CALL_EXPR_ARG (callexp, 2)); + case INTRINSIC_TOPREC: + return expand_intrinsic_toprec (callexp); + case INTRINSIC_VA_ARG: case INTRINSIC_C_VA_ARG: return expand_intrinsic_vaarg (callexp); |