mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-25 05:35:23 +08:00
builtins.c (fold_builtin_1): Treat ccos and ccosh as 'even' functions.
* builtins.c (fold_builtin_1): Treat ccos and ccosh as 'even' functions. * fold-const.c (negate_mathfn_p): Treat casin, casinh, catan, catanh, cproj, csin, csinh, ctan and ctanh as 'odd' functions. testsuite: * gcc.dg/builtins-20.c: Add more cases. * gcc.dg/torture/builtin-symmetric-1.c: Likewise. From-SVN: r121200
This commit is contained in:
parent
db9c839733
commit
4b26d10bcc
@ -1,3 +1,11 @@
|
||||
2007-01-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
|
||||
|
||||
* builtins.c (fold_builtin_1): Treat ccos and ccosh as 'even'
|
||||
functions.
|
||||
|
||||
* fold-const.c (negate_mathfn_p): Treat casin, casinh, catan,
|
||||
catanh, cproj, csin, csinh, ctan and ctanh as 'odd' functions.
|
||||
|
||||
2007-01-25 DJ Delorie <dj@redhat.com>
|
||||
|
||||
* config/m32c/m32c.c (m32c_cannot_change_mode_class): We don't
|
||||
|
@ -9344,6 +9344,18 @@ fold_builtin_1 (tree fndecl, tree arglist, bool ignore)
|
||||
TREE_VALUE (arglist)));
|
||||
break;
|
||||
|
||||
CASE_FLT_FN (BUILT_IN_CCOS):
|
||||
CASE_FLT_FN (BUILT_IN_CCOSH):
|
||||
/* These functions are "even", i.e. f(x) == f(-x). */
|
||||
if (validate_arglist (arglist, COMPLEX_TYPE, VOID_TYPE))
|
||||
{
|
||||
tree narg = fold_strip_sign_ops (TREE_VALUE (arglist));
|
||||
if (narg)
|
||||
return build_function_call_expr (fndecl,
|
||||
build_tree_list (NULL_TREE, narg));
|
||||
}
|
||||
break;
|
||||
|
||||
CASE_FLT_FN (BUILT_IN_CABS):
|
||||
return fold_builtin_cabs (arglist, type, fndecl);
|
||||
|
||||
|
@ -913,7 +913,16 @@ negate_mathfn_p (enum built_in_function code)
|
||||
CASE_FLT_FN (BUILT_IN_ASINH):
|
||||
CASE_FLT_FN (BUILT_IN_ATAN):
|
||||
CASE_FLT_FN (BUILT_IN_ATANH):
|
||||
CASE_FLT_FN (BUILT_IN_CASIN):
|
||||
CASE_FLT_FN (BUILT_IN_CASINH):
|
||||
CASE_FLT_FN (BUILT_IN_CATAN):
|
||||
CASE_FLT_FN (BUILT_IN_CATANH):
|
||||
CASE_FLT_FN (BUILT_IN_CBRT):
|
||||
CASE_FLT_FN (BUILT_IN_CPROJ):
|
||||
CASE_FLT_FN (BUILT_IN_CSIN):
|
||||
CASE_FLT_FN (BUILT_IN_CSINH):
|
||||
CASE_FLT_FN (BUILT_IN_CTAN):
|
||||
CASE_FLT_FN (BUILT_IN_CTANH):
|
||||
CASE_FLT_FN (BUILT_IN_ERF):
|
||||
CASE_FLT_FN (BUILT_IN_LLROUND):
|
||||
CASE_FLT_FN (BUILT_IN_LROUND):
|
||||
|
@ -1,3 +1,8 @@
|
||||
2007-01-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
|
||||
|
||||
* gcc.dg/builtins-20.c: Add more cases.
|
||||
* gcc.dg/torture/builtin-symmetric-1.c: Likewise.
|
||||
|
||||
2007-01-25 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||
|
||||
PR fortran/30437
|
||||
|
@ -23,6 +23,8 @@ extern double fmax (double, double);
|
||||
extern double hypot (double, double);
|
||||
extern double pure (double) __attribute__ ((__pure__));
|
||||
extern double carg (__complex__ double);
|
||||
extern __complex__ double ccos (__complex__ double);
|
||||
extern __complex__ double ctan (__complex__ double);
|
||||
extern float cosf (float);
|
||||
extern float sinf (float);
|
||||
extern float tanf (float);
|
||||
@ -34,6 +36,8 @@ extern float fmaxf (float, float);
|
||||
extern float hypotf (float, float);
|
||||
extern float puref (float) __attribute__ ((__pure__));
|
||||
extern float cargf (__complex__ float);
|
||||
extern __complex__ float ccosf (__complex__ float);
|
||||
extern __complex__ float ctanf (__complex__ float);
|
||||
extern long double cosl (long double);
|
||||
extern long double sinl (long double);
|
||||
extern long double tanl (long double);
|
||||
@ -45,6 +49,8 @@ extern long double fmaxl (long double, long double);
|
||||
extern long double hypotl (long double, long double);
|
||||
extern long double purel (long double) __attribute__ ((__pure__));
|
||||
extern long double cargl (__complex__ long double);
|
||||
extern __complex__ long double ccosl (__complex__ long double);
|
||||
extern __complex__ long double ctanl (__complex__ long double);
|
||||
|
||||
extern void link_error(void);
|
||||
|
||||
@ -193,10 +199,49 @@ void test2(double x, double y)
|
||||
link_error ();
|
||||
}
|
||||
|
||||
void test3(__complex__ double z)
|
||||
void test3(__complex__ double x, __complex__ double y, int i)
|
||||
{
|
||||
if (carg(z) != atan2(__imag__ z, __real__ z))
|
||||
if (carg(x) != atan2(__imag__ x, __real__ x))
|
||||
link_error ();
|
||||
|
||||
if (ccos(x) != ccos(-x))
|
||||
link_error();
|
||||
|
||||
if (ccos(ctan(x)) != ccos(ctan(-x)))
|
||||
link_error();
|
||||
|
||||
if (ctan(x-y) != -ctan(y-x))
|
||||
link_error();
|
||||
|
||||
if (ccos(x/y) != ccos(-x/y))
|
||||
link_error();
|
||||
|
||||
if (ccos(x/y) != ccos(x/-y))
|
||||
link_error();
|
||||
|
||||
if (ccos(x/ctan(y)) != ccos(-x/ctan(-y)))
|
||||
link_error();
|
||||
|
||||
if (ccos(x*y) != ccos(-x*y))
|
||||
link_error();
|
||||
|
||||
if (ccos(x*y) != ccos(x*-y))
|
||||
link_error();
|
||||
|
||||
if (ccos(ctan(x)*y) != ccos(ctan(-x)*-y))
|
||||
link_error();
|
||||
|
||||
if (ccos(ctan(x/y)) != ccos(-ctan(x/-y)))
|
||||
link_error();
|
||||
|
||||
if (ccos(i ? x : y) != ccos(i ? -x : y))
|
||||
link_error();
|
||||
|
||||
if (ccos(i ? x : y) != ccos(i ? x : -y))
|
||||
link_error();
|
||||
|
||||
if (ccos(i ? x : ctan(y/x)) != ccos(i ? -x : -ctan(-y/x)))
|
||||
link_error();
|
||||
}
|
||||
|
||||
void test1f(float x)
|
||||
@ -346,10 +391,49 @@ void test2f(float x, float y)
|
||||
link_error ();
|
||||
}
|
||||
|
||||
void test3f(__complex__ float z)
|
||||
void test3f(__complex__ float x, __complex__ float y, int i)
|
||||
{
|
||||
if (cargf(z) != atan2f(__imag__ z, __real__ z))
|
||||
if (cargf(x) != atan2f(__imag__ x, __real__ x))
|
||||
link_error ();
|
||||
|
||||
if (ccosf(x) != ccosf(-x))
|
||||
link_error();
|
||||
|
||||
if (ccosf(ctanf(x)) != ccosf(ctanf(-x)))
|
||||
link_error();
|
||||
|
||||
if (ctanf(x-y) != -ctanf(y-x))
|
||||
link_error();
|
||||
|
||||
if (ccosf(x/y) != ccosf(-x/y))
|
||||
link_error();
|
||||
|
||||
if (ccosf(x/y) != ccosf(x/-y))
|
||||
link_error();
|
||||
|
||||
if (ccosf(x/ctanf(y)) != ccosf(-x/ctanf(-y)))
|
||||
link_error();
|
||||
|
||||
if (ccosf(x*y) != ccosf(-x*y))
|
||||
link_error();
|
||||
|
||||
if (ccosf(x*y) != ccosf(x*-y))
|
||||
link_error();
|
||||
|
||||
if (ccosf(ctanf(x)*y) != ccosf(ctanf(-x)*-y))
|
||||
link_error();
|
||||
|
||||
if (ccosf(ctanf(x/y)) != ccosf(-ctanf(x/-y)))
|
||||
link_error();
|
||||
|
||||
if (ccosf(i ? x : y) != ccosf(i ? -x : y))
|
||||
link_error();
|
||||
|
||||
if (ccosf(i ? x : y) != ccosf(i ? x : -y))
|
||||
link_error();
|
||||
|
||||
if (ccosf(i ? x : ctanf(y/x)) != ccosf(i ? -x : -ctanf(-y/x)))
|
||||
link_error();
|
||||
}
|
||||
|
||||
void test1l(long double x)
|
||||
@ -499,10 +583,49 @@ void test2l(long double x, long double y)
|
||||
link_error ();
|
||||
}
|
||||
|
||||
void test3l(__complex__ long double z)
|
||||
void test3l(__complex__ long double x, __complex__ long double y, int i)
|
||||
{
|
||||
if (cargl(z) != atan2l(__imag__ z, __real__ z))
|
||||
if (cargl(x) != atan2l(__imag__ x, __real__ x))
|
||||
link_error ();
|
||||
|
||||
if (ccosl(x) != ccosl(-x))
|
||||
link_error();
|
||||
|
||||
if (ccosl(ctanl(x)) != ccosl(ctanl(-x)))
|
||||
link_error();
|
||||
|
||||
if (ctanl(x-y) != -ctanl(y-x))
|
||||
link_error();
|
||||
|
||||
if (ccosl(x/y) != ccosl(-x/y))
|
||||
link_error();
|
||||
|
||||
if (ccosl(x/y) != ccosl(x/-y))
|
||||
link_error();
|
||||
|
||||
if (ccosl(x/ctanl(y)) != ccosl(-x/ctanl(-y)))
|
||||
link_error();
|
||||
|
||||
if (ccosl(x*y) != ccosl(-x*y))
|
||||
link_error();
|
||||
|
||||
if (ccosl(x*y) != ccosl(x*-y))
|
||||
link_error();
|
||||
|
||||
if (ccosl(ctanl(x)*y) != ccosl(ctanl(-x)*-y))
|
||||
link_error();
|
||||
|
||||
if (ccosl(ctanl(x/y)) != ccosl(-ctanl(x/-y)))
|
||||
link_error();
|
||||
|
||||
if (ccosl(i ? x : y) != ccosl(i ? -x : y))
|
||||
link_error();
|
||||
|
||||
if (ccosl(i ? x : y) != ccosl(i ? x : -y))
|
||||
link_error();
|
||||
|
||||
if (ccosl(i ? x : ctanl(y/x)) != ccosl(i ? -x : -ctanl(-y/x)))
|
||||
link_error();
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -21,6 +21,16 @@ extern void link_error(int);
|
||||
link_error(__LINE__); \
|
||||
} while (0)
|
||||
|
||||
/* Test that FUNC(-ARG) == FUNC(ARG), where ARG has a complex type. */
|
||||
#define TESTIT_EVEN_C(FUNC) do { \
|
||||
if (__builtin_##FUNC##f(-cxf) != __builtin_##FUNC##f(cxf)) \
|
||||
link_error(__LINE__); \
|
||||
if (__builtin_##FUNC(-cx) != __builtin_##FUNC(cx)) \
|
||||
link_error(__LINE__); \
|
||||
if (__builtin_##FUNC##l(-cxl) != __builtin_##FUNC##l(cxl)) \
|
||||
link_error(__LINE__); \
|
||||
} while (0)
|
||||
|
||||
/* Test that FUNC(-VAR) == FUNC(VAR), where VAR has an int type. */
|
||||
#define TESTIT_EVEN_I(FUNC,VAR) do { \
|
||||
if (__builtin_##FUNC(-VAR) != __builtin_##FUNC(VAR)) \
|
||||
@ -37,13 +47,28 @@ extern void link_error(int);
|
||||
link_error(__LINE__); \
|
||||
} while (0)
|
||||
|
||||
/* Test that -FUNC(ARG) == FUNC(-ARG), where ARG has a complex type. */
|
||||
#define TESTIT_ODD_C(FUNC) do { \
|
||||
if (-__builtin_##FUNC##f(-cxf) != __builtin_##FUNC##f(cxf)) \
|
||||
link_error(__LINE__); \
|
||||
if (-__builtin_##FUNC(-cx) != __builtin_##FUNC(cx)) \
|
||||
link_error(__LINE__); \
|
||||
if (-__builtin_##FUNC##l(-cxl) != __builtin_##FUNC##l(cxl)) \
|
||||
link_error(__LINE__); \
|
||||
} while (0)
|
||||
|
||||
void foo (float xf, double x, long double xl,
|
||||
__complex__ float cxf, __complex__ double cx, __complex__ long double cxl,
|
||||
int i, long l, long long ll, __INTMAX_TYPE__ im)
|
||||
{
|
||||
TESTIT_EVEN(cos);
|
||||
TESTIT_EVEN(cosh);
|
||||
TESTIT_EVEN(fabs);
|
||||
|
||||
TESTIT_EVEN_C(ccos);
|
||||
TESTIT_EVEN_C(ccosh);
|
||||
TESTIT_EVEN_C(cabs);
|
||||
|
||||
TESTIT_EVEN_I(abs, i);
|
||||
TESTIT_EVEN_I(imaxabs, im);
|
||||
TESTIT_EVEN_I(labs, l);
|
||||
@ -67,10 +92,20 @@ void foo (float xf, double x, long double xl,
|
||||
TESTIT_ODD(tan);
|
||||
TESTIT_ODD(tanh);
|
||||
TESTIT_ODD(trunc);
|
||||
|
||||
TESTIT_ODD_C(casin);
|
||||
TESTIT_ODD_C(casinh);
|
||||
TESTIT_ODD_C(catan);
|
||||
TESTIT_ODD_C(catanh);
|
||||
TESTIT_ODD_C(cproj);
|
||||
TESTIT_ODD_C(csin);
|
||||
TESTIT_ODD_C(csinh);
|
||||
TESTIT_ODD_C(ctan);
|
||||
TESTIT_ODD_C(ctanh);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
foo (1,1,1,1,1,1,1);
|
||||
foo (1,1,1,1,1,1,1,1,1,1);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user