Commit ead6d15f by Andrew Pinski Committed by Andrew Pinski

re PR fortran/17030 (gfortran does not optimize ABS of complex that well)

2004-08-15  Andrew Pinski  <apinski@apple.com>

        PR fortran/17030
        * f95-lang.c (gfc_init_builtin_functions): Initialize the builtins
        for cabs{,f} and copysign{,f}.
        * trans-decl.c (gfor_fndecl_math_cabsf): Delete.
        (gfor_fndecl_math_cabs): Delete.
        (gfor_fndecl_math_sign4): Delete.
        (gfor_fndecl_math_sign8): Delete.
        (gfc_build_intrinsic_function_decls): Remove the
        initializing of cabs{,f} and copysign{,f} functions.
        * trans-intrinsic.c (gfc_conv_intrinsic_abs): Use the builtins
        instead of the functions definitions.
        (gfc_conv_intrinsic_sign): Likewise.
        * trans.h (gfor_fndecl_math_cabsf): Delete.
        (gfor_fndecl_math_cabs): Delete.
        (gfor_fndecl_math_sign4): Delete.
        (gfor_fndecl_math_sign8): Delete.

From-SVN: r86027
parent 23d4fa49
2004-08-15 Andrew Pinski <apinski@apple.com>
PR fortran/17030
* f95-lang.c (gfc_init_builtin_functions): Initialize the builtins
for cabs{,f} and copysign{,f}.
* trans-decl.c (gfor_fndecl_math_cabsf): Delete.
(gfor_fndecl_math_cabs): Delete.
(gfor_fndecl_math_sign4): Delete.
(gfor_fndecl_math_sign8): Delete.
(gfc_build_intrinsic_function_decls): Remove the
initializing of cabs{,f} and copysign{,f} functions.
* trans-intrinsic.c (gfc_conv_intrinsic_abs): Use the builtins
instead of the functions definitions.
(gfc_conv_intrinsic_sign): Likewise.
* trans.h (gfor_fndecl_math_cabsf): Delete.
(gfor_fndecl_math_cabs): Delete.
(gfor_fndecl_math_sign4): Delete.
(gfor_fndecl_math_sign8): Delete.
2004-08-15 Nathan Sidwell <nathan@codesourcery.com>
* trans-array.c (gfc_trans_array_constructor_value): Use
......
......@@ -723,6 +723,8 @@ gfc_init_builtin_functions (void)
{
tree mfunc_float[2];
tree mfunc_double[2];
tree func_cfloat_float;
tree func_cdouble_double;
tree ftype;
tree tmp;
......@@ -730,11 +732,19 @@ gfc_init_builtin_functions (void)
mfunc_float[0] = build_function_type (float_type_node, tmp);
tmp = tree_cons (NULL_TREE, float_type_node, tmp);
mfunc_float[1] = build_function_type (float_type_node, tmp);
tmp = tree_cons (NULL_TREE, complex_float_type_node, void_list_node);
func_cfloat_float = build_function_type (float_type_node, tmp);
tmp = tree_cons (NULL_TREE, double_type_node, void_list_node);
mfunc_double[0] = build_function_type (double_type_node, tmp);
tmp = tree_cons (NULL_TREE, double_type_node, tmp);
mfunc_double[1] = build_function_type (double_type_node, tmp);
tmp = tree_cons (NULL_TREE, complex_double_type_node, void_list_node);
func_cdouble_double = build_function_type (double_type_node, tmp);
#include "mathbuiltins.def"
......@@ -748,6 +758,17 @@ gfc_init_builtin_functions (void)
BUILT_IN_ROUND, "round", true);
gfc_define_builtin ("__builtin_roundf", mfunc_float[0],
BUILT_IN_ROUNDF, "roundf", true);
gfc_define_builtin ("__builtin_cabs", func_cdouble_double,
BUILT_IN_CABS, "cabs", true);
gfc_define_builtin ("__builtin_cabsf", func_cfloat_float,
BUILT_IN_CABSF, "cabsf", true);
gfc_define_builtin ("__builtin_copysign", mfunc_double[1],
BUILT_IN_COPYSIGN, "copysign", true);
gfc_define_builtin ("__builtin_copysignf", mfunc_float[1],
BUILT_IN_COPYSIGNF, "copysignf", true);
/* These are used to implement the ** operator. */
gfc_define_builtin ("__builtin_pow", mfunc_double[1],
......
......@@ -96,10 +96,6 @@ tree gfor_fndecl_associated;
gfc_powdecl_list gfor_fndecl_math_powi[3][2];
tree gfor_fndecl_math_cpowf;
tree gfor_fndecl_math_cpow;
tree gfor_fndecl_math_cabsf;
tree gfor_fndecl_math_cabs;
tree gfor_fndecl_math_sign4;
tree gfor_fndecl_math_sign8;
tree gfor_fndecl_math_ishftc4;
tree gfor_fndecl_math_ishftc8;
tree gfor_fndecl_math_exponent4;
......@@ -1460,22 +1456,6 @@ gfc_build_intrinsic_function_decls (void)
gfc_build_library_function_decl (get_identifier ("cpow"),
gfc_complex8_type_node,
1, gfc_complex8_type_node);
gfor_fndecl_math_cabsf =
gfc_build_library_function_decl (get_identifier ("cabsf"),
gfc_real4_type_node,
1, gfc_complex4_type_node);
gfor_fndecl_math_cabs =
gfc_build_library_function_decl (get_identifier ("cabs"),
gfc_real8_type_node,
1, gfc_complex8_type_node);
gfor_fndecl_math_sign4 =
gfc_build_library_function_decl (get_identifier ("copysignf"),
gfc_real4_type_node,
1, gfc_real4_type_node);
gfor_fndecl_math_sign8 =
gfc_build_library_function_decl (get_identifier ("copysign"),
gfc_real8_type_node,
1, gfc_real8_type_node);
gfor_fndecl_math_ishftc4 =
gfc_build_library_function_decl (get_identifier (PREFIX("ishftc4")),
gfc_int4_type_node,
......
......@@ -703,7 +703,7 @@ gfc_conv_intrinsic_abs (gfc_se * se, gfc_expr * expr)
{
tree args;
tree val;
tree fndecl;
int n;
args = gfc_conv_intrinsic_function_args (se, expr);
assert (args && TREE_CHAIN (args) == NULL_TREE);
......@@ -720,15 +720,15 @@ gfc_conv_intrinsic_abs (gfc_se * se, gfc_expr * expr)
switch (expr->ts.kind)
{
case 4:
fndecl = gfor_fndecl_math_cabsf;
n = BUILT_IN_CABSF;
break;
case 8:
fndecl = gfor_fndecl_math_cabs;
n = BUILT_IN_CABS;
break;
default:
abort ();
}
se->expr = gfc_build_function_call (fndecl, args);
se->expr = fold (gfc_build_function_call (built_in_decls[n], args));
break;
default:
......@@ -893,15 +893,15 @@ gfc_conv_intrinsic_sign (gfc_se * se, gfc_expr * expr)
switch (expr->ts.kind)
{
case 4:
tmp = gfor_fndecl_math_sign4;
tmp = built_in_decls[BUILT_IN_COPYSIGNF];
break;
case 8:
tmp = gfor_fndecl_math_sign8;
tmp = built_in_decls[BUILT_IN_COPYSIGN];
break;
default:
abort ();
}
se->expr = gfc_build_function_call (tmp, arg);
se->expr = fold (gfc_build_function_call (tmp, arg));
return;
}
......
......@@ -465,10 +465,6 @@ gfc_powdecl_list;
extern GTY(()) gfc_powdecl_list gfor_fndecl_math_powi[3][2];
extern GTY(()) tree gfor_fndecl_math_cpowf;
extern GTY(()) tree gfor_fndecl_math_cpow;
extern GTY(()) tree gfor_fndecl_math_cabsf;
extern GTY(()) tree gfor_fndecl_math_cabs;
extern GTY(()) tree gfor_fndecl_math_sign4;
extern GTY(()) tree gfor_fndecl_math_sign8;
extern GTY(()) tree gfor_fndecl_math_ishftc4;
extern GTY(()) tree gfor_fndecl_math_ishftc8;
extern GTY(()) tree gfor_fndecl_math_exponent4;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment