aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2004-03-19 03:20:04 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2004-03-19 03:20:04 +0000
commitb381036092ab446b8bf51c5f4f6ff7dd2eaf8608 (patch)
tree1789c618755f2ba2580988dfc66c1b24db0fd9d2
parent9d363a56a8ff6587f8d32ea380b55fea77ea5f13 (diff)
downloadgcc-b381036092ab446b8bf51c5f4f6ff7dd2eaf8608.zip
gcc-b381036092ab446b8bf51c5f4f6ff7dd2eaf8608.tar.gz
gcc-b381036092ab446b8bf51c5f4f6ff7dd2eaf8608.tar.bz2
* convert.c (convert_to_real): Reformat using switch stmt.
From-SVN: r79667
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/convert.c70
2 files changed, 41 insertions, 33 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c33d57b..e24e339 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2004-03-18 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * convert.c (convert_to_real): Reformat using switch stmt.
+
2004-03-18 Mark Mitchell <mark@codesourcery.com>
* c-common.c (pointer_int_sum): Do not complain about using
diff --git a/gcc/convert.c b/gcc/convert.c
index 554cd48..7224277 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -131,44 +131,48 @@ convert_to_real (tree type, tree expr)
present in runtime. */
/* Convert (float)sqrt((double)x) where x is float into sqrtf(x) */
if (optimize
- && (fcode == BUILT_IN_SQRT
- || fcode == BUILT_IN_SQRTL
- || fcode == BUILT_IN_SIN
- || fcode == BUILT_IN_SINL
- || fcode == BUILT_IN_COS
- || fcode == BUILT_IN_COSL
- || fcode == BUILT_IN_EXP
- || fcode == BUILT_IN_EXPL
- || fcode == BUILT_IN_LOG
- || fcode == BUILT_IN_LOGL)
&& (TYPE_MODE (type) == TYPE_MODE (double_type_node)
|| TYPE_MODE (type) == TYPE_MODE (float_type_node)))
{
- tree arg0 = strip_float_extensions (TREE_VALUE (TREE_OPERAND (expr, 1)));
- tree newtype = type;
-
- /* We have (outertype)sqrt((innertype)x). Choose the wider mode from
- the both as the safe type for operation. */
- if (TYPE_PRECISION (TREE_TYPE (arg0)) > TYPE_PRECISION (type))
- newtype = TREE_TYPE (arg0);
-
- /* Be careful about integer to fp conversions.
- These may overflow still. */
- if (FLOAT_TYPE_P (TREE_TYPE (arg0))
- && TYPE_PRECISION (newtype) < TYPE_PRECISION (itype)
- && (TYPE_MODE (newtype) == TYPE_MODE (double_type_node)
- || TYPE_MODE (newtype) == TYPE_MODE (float_type_node)))
- {
- tree arglist;
- tree fn = mathfn_built_in (newtype, fcode);
-
- if (fn)
+ switch (fcode)
+ {
+#define CASE_MATHFN(FN) case BUILT_IN_##FN: case BUILT_IN_##FN##L:
+ CASE_MATHFN (SQRT)
+ CASE_MATHFN (SIN)
+ CASE_MATHFN (COS)
+ CASE_MATHFN (EXP)
+ CASE_MATHFN (LOG)
+#undef CASE_MATHFN
{
- arglist = build_tree_list (NULL_TREE, fold (convert_to_real (newtype, arg0)));
- expr = build_function_call_expr (fn, arglist);
- if (newtype == type)
- return expr;
+ tree arg0 = strip_float_extensions (TREE_VALUE (TREE_OPERAND (expr, 1)));
+ tree newtype = type;
+
+ /* We have (outertype)sqrt((innertype)x). Choose the wider mode from
+ the both as the safe type for operation. */
+ if (TYPE_PRECISION (TREE_TYPE (arg0)) > TYPE_PRECISION (type))
+ newtype = TREE_TYPE (arg0);
+
+ /* Be careful about integer to fp conversions.
+ These may overflow still. */
+ if (FLOAT_TYPE_P (TREE_TYPE (arg0))
+ && TYPE_PRECISION (newtype) < TYPE_PRECISION (itype)
+ && (TYPE_MODE (newtype) == TYPE_MODE (double_type_node)
+ || TYPE_MODE (newtype) == TYPE_MODE (float_type_node)))
+ {
+ tree arglist;
+ tree fn = mathfn_built_in (newtype, fcode);
+
+ if (fn)
+ {
+ arglist = build_tree_list (NULL_TREE, fold (convert_to_real (newtype, arg0)));
+ expr = build_function_call_expr (fn, arglist);
+ if (newtype == type)
+ return expr;
+ }
+ }
}
+ default:
+ break;
}
}
if (optimize