diff options
author | Eric Botcazou <ebotcazou@libertysurf.fr> | 2005-10-11 20:14:57 +0200 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2005-10-11 18:14:57 +0000 |
commit | 5e8b5b0868f23c72e9a4789196c60d076f2ef580 (patch) | |
tree | ca8173c7024ef726758670595befc31e1b2edb0b /gcc | |
parent | 8c07e3d7a7ef1e24c8f1b137331fab65e210cf94 (diff) | |
download | gcc-5e8b5b0868f23c72e9a4789196c60d076f2ef580.zip gcc-5e8b5b0868f23c72e9a4789196c60d076f2ef580.tar.gz gcc-5e8b5b0868f23c72e9a4789196c60d076f2ef580.tar.bz2 |
re PR middle-end/24263 (gcc.dg/torture/builtin-convert-1.c fails)
PR middle-end/24263
* convert.c (convert_to_real): Revert 2005-10-05 patch.
Only apply the optimization for rounding builtins if the inner
cast is also an extension.
From-SVN: r105249
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/convert.c | 38 |
2 files changed, 42 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4c063b..1b1faaa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2005-10-11 Eric Botcazou <ebotcazou@libertysurf.fr> + + PR middle-end/24263 + * convert.c (convert_to_real): Revert 2005-10-05 patch. + Only apply the optimization for rounding builtins if the inner + cast is also an extension. + 2005-10-11 Andrew Pinski <pinskia@physics.uc.edu> PR tree-opt/23946 diff --git a/gcc/convert.c b/gcc/convert.c index 471d93d..5680c39 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -200,9 +200,41 @@ convert_to_real (tree type, tree expr) break; } } - /* This code formerly changed (float)floor(double d) to - floorf((float)d). This is incorrect, because (float)d uses - round-to-nearest and can round up to the next integer. */ + if (optimize + && (((fcode == BUILT_IN_FLOORL + || fcode == BUILT_IN_CEILL + || fcode == BUILT_IN_ROUNDL + || fcode == BUILT_IN_RINTL + || fcode == BUILT_IN_TRUNCL + || fcode == BUILT_IN_NEARBYINTL) + && (TYPE_MODE (type) == TYPE_MODE (double_type_node) + || TYPE_MODE (type) == TYPE_MODE (float_type_node))) + || ((fcode == BUILT_IN_FLOOR + || fcode == BUILT_IN_CEIL + || fcode == BUILT_IN_ROUND + || fcode == BUILT_IN_RINT + || fcode == BUILT_IN_TRUNC + || fcode == BUILT_IN_NEARBYINT) + && (TYPE_MODE (type) == TYPE_MODE (float_type_node))))) + { + tree fn = mathfn_built_in (type, fcode); + + if (fn) + { + tree arg + = strip_float_extensions (TREE_VALUE (TREE_OPERAND (expr, 1))); + + /* Make sure (type)arg0 is an extension, otherwise we could end up + changing (float)floor(double d) into floorf((float)d), which is + incorrect because (float)d uses round-to-nearest and can round + up to the next integer. */ + if (TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (arg))) + return + build_function_call_expr (fn, + build_tree_list (NULL_TREE, + fold (convert_to_real (type, arg)))); + } + } /* Propagate the cast into the operation. */ if (itype != type && FLOAT_TYPE_P (type)) |