summaryrefslogtreecommitdiff
path: root/gcc/convert.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-18 12:39:23 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-18 12:39:23 +0000
commit2b80dc46855486d6871e58511259f4b601dffcd9 (patch)
treeb438afbff1f87123b228fcb914c7ee7f802e3879 /gcc/convert.c
parent61c95d27915f6edaaf10f4aaaa29e39bd8d7611f (diff)
downloadgcc-2b80dc46855486d6871e58511259f4b601dffcd9.tar.gz
2009-06-18 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r148653 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@148658 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/convert.c')
-rw-r--r--gcc/convert.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/convert.c b/gcc/convert.c
index b6a9d3dc531..8245e1647fb 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -482,6 +482,37 @@ convert_to_integer (tree type, tree expr)
}
}
+ /* Convert (int)logb(d) -> ilogb(d). */
+ if (optimize
+ && flag_unsafe_math_optimizations
+ && !flag_trapping_math && !flag_errno_math && flag_finite_math_only
+ && integer_type_node
+ && (outprec > TYPE_PRECISION (integer_type_node)
+ || (outprec == TYPE_PRECISION (integer_type_node)
+ && !TYPE_UNSIGNED (type))))
+ {
+ tree s_expr = strip_float_extensions (expr);
+ tree s_intype = TREE_TYPE (s_expr);
+ const enum built_in_function fcode = builtin_mathfn_code (s_expr);
+ tree fn = 0;
+
+ switch (fcode)
+ {
+ CASE_FLT_FN (BUILT_IN_LOGB):
+ fn = mathfn_built_in (s_intype, BUILT_IN_ILOGB);
+ break;
+
+ default:
+ break;
+ }
+
+ if (fn)
+ {
+ tree newexpr = build_call_expr (fn, 1, CALL_EXPR_ARG (s_expr, 0));
+ return convert_to_integer (type, newexpr);
+ }
+ }
+
switch (TREE_CODE (intype))
{
case POINTER_TYPE: