aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2006-07-27 14:02:27 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2006-07-27 14:02:27 +0000
commit482c6ce8854e83bb5d89f367cf2a391e454c4735 (patch)
tree8f719633623f288ed24eae0d3489f6505aeb6a66 /gcc/builtins.c
parent721cedf2517390c2fd7b7f2c3272177ff1a50f10 (diff)
downloadgcc-482c6ce8854e83bb5d89f367cf2a391e454c4735.zip
gcc-482c6ce8854e83bb5d89f367cf2a391e454c4735.tar.gz
gcc-482c6ce8854e83bb5d89f367cf2a391e454c4735.tar.bz2
builtins.c (fold_fixed_mathfn): When long and long long are the same size...
* builtins.c (fold_fixed_mathfn): When long and long long are the same size, canonicalize llceil*, llfloor*, llround* and llrint* functions to their lceil*, lfloor*, lround* and lrint* forms. * gcc.dg/builtins-55.c: New test case. From-SVN: r115775
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 80f2fbb..47c61cd 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -6772,6 +6772,42 @@ fold_fixed_mathfn (tree fndecl, tree arglist)
return build_function_call_expr (decl, arglist);
}
}
+
+ /* Canonicalize llround (x) to lround (x) on LP64 targets where
+ sizeof (long long) == sizeof (long). */
+ if (TYPE_PRECISION (long_long_integer_type_node)
+ == TYPE_PRECISION (long_integer_type_node))
+ {
+ tree newfn = NULL_TREE;
+ switch (fcode)
+ {
+ CASE_FLT_FN (BUILT_IN_LLCEIL):
+ newfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_LCEIL);
+ break;
+
+ CASE_FLT_FN (BUILT_IN_LLFLOOR):
+ newfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_LFLOOR);
+ break;
+
+ CASE_FLT_FN (BUILT_IN_LLROUND):
+ newfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_LROUND);
+ break;
+
+ CASE_FLT_FN (BUILT_IN_LLRINT):
+ newfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_LRINT);
+ break;
+
+ default:
+ break;
+ }
+
+ if (newfn)
+ {
+ tree newcall = build_function_call_expr (newfn, arglist);
+ return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), newcall);
+ }
+ }
+
return 0;
}