diff options
author | Richard Biener <rguenther@suse.de> | 2021-10-27 14:27:40 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-10-28 11:28:42 +0200 |
commit | a84b9d5373c7e67fd0ab2a412c22162cdf969c91 (patch) | |
tree | d3211aa3a240ba0ab3043df237ed2ac37a35f5a9 /gcc/fold-const.c | |
parent | eed248bb8cc3091e8a9b2f73138c691396752438 (diff) | |
download | gcc-a84b9d5373c7e67fd0ab2a412c22162cdf969c91.zip gcc-a84b9d5373c7e67fd0ab2a412c22162cdf969c91.tar.gz gcc-a84b9d5373c7e67fd0ab2a412c22162cdf969c91.tar.bz2 |
middle-end/57245 - honor -frounding-math in real truncation
The following honors -frounding-math when converting a FP constant
to another FP type.
2021-10-27 Richard Biener <rguenther@suse.de>
PR middle-end/57245
* fold-const.c (fold_convert_const_real_from_real): Honor
-frounding-math if the conversion is not exact.
* simplify-rtx.c (simplify_const_unary_operation): Do not
simplify FLOAT_TRUNCATE with sign dependent rounding.
* gcc.dg/torture/fp-double-convert-float-1.c: New testcase.
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ff23f12..18950ae 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2139,6 +2139,12 @@ fold_convert_const_real_from_real (tree type, const_tree arg1) && REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (arg1))) return NULL_TREE; + /* With flag_rounding_math we should respect the current rounding mode + unless the conversion is exact. */ + if (HONOR_SIGN_DEPENDENT_ROUNDING (arg1) + && !exact_real_truncate (TYPE_MODE (type), &TREE_REAL_CST (arg1))) + return NULL_TREE; + real_convert (&value, TYPE_MODE (type), &TREE_REAL_CST (arg1)); t = build_real (type, value); |