builtins.c (fold_builtin_1): Support complex "arc" functions.

* builtins.c (fold_builtin_1): Support complex "arc" functions.
	* real.h (HAVE_mpc_arc): Define.

testsuite:
	* gcc.dg/torture/builtin-math-6.c: Test complex "arc" functions.
	* lib/target-supports.exp (check_effective_target_mpc_arc): New.

From-SVN: r152746
This commit is contained in:
Kaveh R. Ghazi 2009-10-14 01:14:53 +00:00 committed by Kaveh Ghazi
parent 1cc245760c
commit 7610abd8cb
6 changed files with 119 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2009-10-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.c (fold_builtin_1): Support complex "arc" functions.
* real.h (HAVE_mpc_arc): Define.
2009-10-14 Kaz Kojima <kkojima@gcc.gnu.org>
* config/sh/sh.c (TARGET_BUILTIN_DECL): Define.

View File

@ -10063,7 +10063,45 @@ fold_builtin_1 (location_t loc, tree fndecl, tree arg0, bool ignore)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
return do_mpc_arg1 (arg0, type, mpc_sqrt);
break;
#endif
#ifdef HAVE_mpc_arc
CASE_FLT_FN (BUILT_IN_CASIN):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
return do_mpc_arg1 (arg0, type, mpc_asin);
break;
CASE_FLT_FN (BUILT_IN_CACOS):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
return do_mpc_arg1 (arg0, type, mpc_acos);
break;
CASE_FLT_FN (BUILT_IN_CATAN):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
return do_mpc_arg1 (arg0, type, mpc_atan);
break;
CASE_FLT_FN (BUILT_IN_CASINH):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
return do_mpc_arg1 (arg0, type, mpc_asinh);
break;
CASE_FLT_FN (BUILT_IN_CACOSH):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
return do_mpc_arg1 (arg0, type, mpc_acosh);
break;
CASE_FLT_FN (BUILT_IN_CATANH):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
return do_mpc_arg1 (arg0, type, mpc_atanh);
break;
#endif /* HAVE_mpc_arc */
#endif /* HAVE_mpc */
CASE_FLT_FN (BUILT_IN_CABS):
return fold_builtin_cabs (loc, arg0, type, fndecl);

View File

@ -32,6 +32,9 @@ extern tree do_mpc_arg2 (tree, tree, tree, int, int (*)(mpc_ptr, mpc_srcptr, mpc
# if MPC_VERSION >= MPC_VERSION_NUM(0,6,1)
# define HAVE_mpc_pow
# endif
# if MPC_VERSION >= MPC_VERSION_NUM(0,7,1)
# define HAVE_mpc_arc
# endif
#endif
#endif
#include "machmode.h"

View File

@ -1,3 +1,8 @@
2009-10-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/torture/builtin-math-6.c: Test complex "arc" functions.
* lib/target-supports.exp (check_effective_target_mpc_arc): New.
2009-10-14 Hans-Peter Nilsson <hp@axis.com>
PR target/38948

View File

@ -6,7 +6,7 @@
Origin: Kaveh R. Ghazi, January 28, 2009. */
/* { dg-do link } */
/* { dg-require-effective-target mpc_pow } */
/* { dg-require-effective-target mpc_arc } */
/* All references to link_error should go away at compile-time. The
first number is the line number and the second is the value number
@ -180,9 +180,48 @@ extern void link_error(int, int);
int main (void)
{
TESTIT_COMPLEX (1, cacos, 1, CONJ(0));
TESTIT_COMPLEX_R (1, cacos, -1, CONJ(3.141593F));
TESTIT_COMPLEX (1, cacos, CONJ(1), 0);
TESTIT_COMPLEX_R (1, cacos, CONJ(-1), 3.141593F);
TESTIT_COMPLEX_R_ALLNEG (cacos, 3.45678F + 2.34567FI,
0.60971F - 2.11780FI, 2.531875F - 2.117800FI,
0.60971F + 2.11780FI, 2.531875F + 2.117800FI);
TESTIT_COMPLEX_ALLNEG (casin, 0,
0, -CONJ(0), CONJ(0), CONJ(-0.F));
TESTIT_COMPLEX_R_ALLNEG (casin, 3.45678F + 2.34567FI,
0.96107F + 2.11780FI, -0.96107F + 2.11780FI,
0.96107F - 2.11780FI, -0.96107F - 2.11780FI);
TESTIT_COMPLEX_ALLNEG (catan, 0,
0, -CONJ(0), CONJ(0), CONJ(-0.F));
TESTIT_COMPLEX_R_ALLNEG (catan, 3.45678F + 2.34567FI,
1.37188F + 0.12997FI, -1.37188F + 0.12997FI,
1.37188F - 0.12997FI, -1.37188F - 0.12997FI);
TESTIT_COMPLEX (1, cacosh, 1, 0);
TESTIT_COMPLEX_R (1, cacosh, -1, 3.141593FI);
TESTIT_COMPLEX (1, cacosh, CONJ(1), CONJ(0));
TESTIT_COMPLEX_R (1, cacosh, CONJ(-1), CONJ(3.141593FI));
TESTIT_COMPLEX_R_ALLNEG (cacosh, 3.45678F + 2.34567FI,
2.11780F + 0.60971FI, 2.11780F + 2.531875FI,
2.11780F - 0.60971FI, 2.11780F - 2.531875FI);
TESTIT_COMPLEX_ALLNEG (casinh, 0,
0, -CONJ(0), CONJ(0), CONJ(-0.F));
TESTIT_COMPLEX_R_ALLNEG (casinh, 3.45678F + 2.34567FI,
2.12836F + 0.58310FI, -2.12836F + 0.58310FI,
2.12836F - 0.58310FI, -2.12836F - 0.58310FI);
TESTIT_COMPLEX_ALLNEG (catanh, 0,
0, -CONJ(0), CONJ(0), CONJ(-0.F));
TESTIT_COMPLEX_R_ALLNEG (catanh, 3.45678F + 2.34567FI,
0.19693F + 1.43190FI, -0.19693F + 1.43190FI,
0.19693F - 1.43190FI, -0.19693F - 1.43190FI);
TESTIT_COMPLEX_ALLNEG (csin, 0,
0, -0.F,
CONJ(0), CONJ(-0.F));
0, -0.F, CONJ(0), CONJ(-0.F));
TESTIT_COMPLEX_R_ALLNEG (csin, 3.45678F + 2.34567FI,
-1.633059F - 4.917448FI, 1.633059F - 4.917448FI,
-1.633059F + 4.917448FI, 1.633059F + 4.917448FI);
@ -219,8 +258,8 @@ int main (void)
TESTIT_COMPLEX (1, clog, 1, 0);
TESTIT_COMPLEX_R (1, clog, -1, 3.141593FI);
TESTIT_COMPLEX (1, clog, CONJ(1), CONJ(0)); /* Fails with mpc-0.6. */
TESTIT_COMPLEX_R (1, clog, CONJ(-1), CONJ(3.141593FI)); /* Fails with mpc-0.6. */
TESTIT_COMPLEX (1, clog, CONJ(1), CONJ(0));
TESTIT_COMPLEX_R (1, clog, CONJ(-1), CONJ(3.141593FI));
TESTIT_COMPLEX_R_ALLNEG (clog, 3.45678F + 2.34567FI,
1.429713F + 0.596199FI, 1.429713F + 2.545394FI,
1.429713F - 0.596199FI, 1.429713F - 2.545394FI);

View File

@ -3127,6 +3127,29 @@ proc check_effective_target_mpc_pow { } {
}]
}
# Return 1 if the MPC library with "arc" functions is integrated with GCC, 0 otherwise.
proc check_effective_target_mpc_arc { } {
return [check_no_compiler_messages mpc_arc executable {
extern void link_error(void);
int main ()
{
if (__builtin_cacos(1) != 0)
link_error();
if (__builtin_casin(0) != 0)
link_error();
if (__builtin_catan(0) != 0)
link_error();
if (__builtin_cacosh(1) != 0)
link_error();
if (__builtin_casinh(0) != 0)
link_error();
if (__builtin_catanh(0) != 0)
link_error();
}
}]
}
# Return 1 if the language for the compiler under test is C.
proc check_effective_target_c { } {