aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorUros Bizjak <uros@kss-loka.si>2004-04-20 21:40:31 +0200
committerRoger Sayle <sayle@gcc.gnu.org>2004-04-20 19:40:31 +0000
commitc56122d841f0a8f8941f435e9e0e98d3b04f937b (patch)
treeb8cfb1f808f8cdf2784d4c395572ad76b0931623 /gcc
parent7b1521e0f4d857eb9e533c2ef3ba731e7d521fab (diff)
downloadgcc-c56122d841f0a8f8941f435e9e0e98d3b04f937b.zip
gcc-c56122d841f0a8f8941f435e9e0e98d3b04f937b.tar.gz
gcc-c56122d841f0a8f8941f435e9e0e98d3b04f937b.tar.bz2
optabs.h (enum optab_index): Add new OTI_asin and OTI_acos.
2004-04-20 Uros Bizjak <uros@kss-loka.si> * optabs.h (enum optab_index): Add new OTI_asin and OTI_acos. (asin_optab, acos_optab): Define corresponding macros. * optabs.c (init_optabs): Initialize asin_optab and acos_optab. * genopinit.c (optabs): Implement asin_optab and acos_optab using asin?f2 and acos?f2 patterns. * builtins.c (expand_builtin_mathfn): Handle BUILT_IN_ASIN{,F,L} using asin_optab, and BUILT_IN_ACOS{,F,L} using acos_optab. (expand_builtin): Expand BUILT_IN_ASIN{,F,L} and BUILT_IN_ACOS{,F,L} using expand_builtin_mathfn if flag_unsafe_math_optimizations is set. * config/i386/i386.md (asindf2, asinsf2, asinxf2, acosdf2, acossf2, acosxf2): New expanders to implement asin, asinf, asinl, acos, acosf and acosl built-ins as inline x87 intrinsics. * gcc.dg/builtins-39.c: New test. From-SVN: r80921
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog16
-rw-r--r--gcc/builtins.c14
-rw-r--r--gcc/config/i386/i386.md134
-rw-r--r--gcc/genopinit.c2
-rw-r--r--gcc/optabs.c2
-rw-r--r--gcc/optabs.h6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/builtins-39.c48
8 files changed, 226 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9c58eed..fb0b092 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,19 @@
+2004-04-20 Uros Bizjak <uros@kss-loka.si>
+
+ * optabs.h (enum optab_index): Add new OTI_asin and OTI_acos.
+ (asin_optab, acos_optab): Define corresponding macros.
+ * optabs.c (init_optabs): Initialize asin_optab and acos_optab.
+ * genopinit.c (optabs): Implement asin_optab and acos_optab
+ using asin?f2 and acos?f2 patterns.
+ * builtins.c (expand_builtin_mathfn): Handle BUILT_IN_ASIN{,F,L}
+ using asin_optab, and BUILT_IN_ACOS{,F,L} using acos_optab.
+ (expand_builtin): Expand BUILT_IN_ASIN{,F,L} and BUILT_IN_ACOS{,F,L}
+ using expand_builtin_mathfn if flag_unsafe_math_optimizations is set.
+
+ * config/i386/i386.md (asindf2, asinsf2, asinxf2, acosdf2,
+ acossf2, acosxf2): New expanders to implement asin, asinf, asinl,
+ acos, acosf and acosl built-ins as inline x87 intrinsics.
+
2004-04-20 Paul Brook <paul@codesourcery.com>
* config/arm/arm.c (arm_legitimate_address_p): Use rtx_equal_p.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 66b4a63..c7627c0 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1585,6 +1585,14 @@ expand_builtin_mathfn (tree exp, rtx target, rtx subtarget)
case BUILT_IN_LOG2F:
case BUILT_IN_LOG2L:
errno_set = true; builtin_optab = log2_optab; break;
+ case BUILT_IN_ASIN:
+ case BUILT_IN_ASINF:
+ case BUILT_IN_ASINL:
+ builtin_optab = asin_optab; break;
+ case BUILT_IN_ACOS:
+ case BUILT_IN_ACOSF:
+ case BUILT_IN_ACOSL:
+ builtin_optab = acos_optab; break;
case BUILT_IN_TAN:
case BUILT_IN_TANF:
case BUILT_IN_TANL:
@@ -5204,6 +5212,12 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
case BUILT_IN_TAN:
case BUILT_IN_TANF:
case BUILT_IN_TANL:
+ case BUILT_IN_ASIN:
+ case BUILT_IN_ASINF:
+ case BUILT_IN_ASINL:
+ case BUILT_IN_ACOS:
+ case BUILT_IN_ACOSF:
+ case BUILT_IN_ACOSL:
case BUILT_IN_ATAN:
case BUILT_IN_ATANF:
case BUILT_IN_ATANL:
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 2c498e0..c0a3ff4 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -15284,6 +15284,140 @@
DONE;
})
+(define_expand "asindf2"
+ [(set (match_dup 2)
+ (float_extend:XF (match_operand:DF 1 "register_operand" "")))
+ (set (match_dup 3) (mult:XF (match_dup 2) (match_dup 2)))
+ (set (match_dup 5) (minus:XF (match_dup 4) (match_dup 3)))
+ (set (match_dup 6) (sqrt:XF (match_dup 5)))
+ (parallel [(set (match_dup 7)
+ (unspec:XF [(match_dup 6) (match_dup 2)]
+ UNSPEC_FPATAN))
+ (clobber (match_scratch:XF 8 ""))])
+ (set (match_operand:DF 0 "register_operand" "")
+ (float_truncate:DF (match_dup 7)))]
+ "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
+ && flag_unsafe_math_optimizations"
+{
+ int i;
+
+ for (i=2; i<8; i++)
+ operands[i] = gen_reg_rtx (XFmode);
+
+ emit_move_insn (operands[4], CONST1_RTX (XFmode)); /* fld1 */
+})
+
+(define_expand "asinsf2"
+ [(set (match_dup 2)
+ (float_extend:XF (match_operand:SF 1 "register_operand" "")))
+ (set (match_dup 3) (mult:XF (match_dup 2) (match_dup 2)))
+ (set (match_dup 5) (minus:XF (match_dup 4) (match_dup 3)))
+ (set (match_dup 6) (sqrt:XF (match_dup 5)))
+ (parallel [(set (match_dup 7)
+ (unspec:XF [(match_dup 6) (match_dup 2)]
+ UNSPEC_FPATAN))
+ (clobber (match_scratch:XF 8 ""))])
+ (set (match_operand:SF 0 "register_operand" "")
+ (float_truncate:SF (match_dup 7)))]
+ "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
+ && flag_unsafe_math_optimizations"
+{
+ int i;
+
+ for (i=2; i<8; i++)
+ operands[i] = gen_reg_rtx (XFmode);
+
+ emit_move_insn (operands[4], CONST1_RTX (XFmode)); /* fld1 */
+})
+
+(define_expand "asinxf2"
+ [(set (match_dup 2)
+ (mult:XF (match_operand:XF 1 "register_operand" "")
+ (match_dup 1)))
+ (set (match_dup 4) (minus:XF (match_dup 3) (match_dup 2)))
+ (set (match_dup 5) (sqrt:XF (match_dup 4)))
+ (parallel [(set (match_operand:XF 0 "register_operand" "")
+ (unspec:XF [(match_dup 5) (match_dup 1)]
+ UNSPEC_FPATAN))
+ (clobber (match_scratch:XF 6 ""))])]
+ "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
+ && flag_unsafe_math_optimizations"
+{
+ int i;
+
+ for (i=2; i<6; i++)
+ operands[i] = gen_reg_rtx (XFmode);
+
+ emit_move_insn (operands[3], CONST1_RTX (XFmode)); /* fld1 */
+})
+
+(define_expand "acosdf2"
+ [(set (match_dup 2)
+ (float_extend:XF (match_operand:DF 1 "register_operand" "")))
+ (set (match_dup 3) (mult:XF (match_dup 2) (match_dup 2)))
+ (set (match_dup 5) (minus:XF (match_dup 4) (match_dup 3)))
+ (set (match_dup 6) (sqrt:XF (match_dup 5)))
+ (parallel [(set (match_dup 7)
+ (unspec:XF [(match_dup 2) (match_dup 6)]
+ UNSPEC_FPATAN))
+ (clobber (match_scratch:XF 8 ""))])
+ (set (match_operand:DF 0 "register_operand" "")
+ (float_truncate:DF (match_dup 7)))]
+ "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
+ && flag_unsafe_math_optimizations"
+{
+ int i;
+
+ for (i=2; i<8; i++)
+ operands[i] = gen_reg_rtx (XFmode);
+
+ emit_move_insn (operands[4], CONST1_RTX (XFmode)); /* fld1 */
+})
+
+(define_expand "acossf2"
+ [(set (match_dup 2)
+ (float_extend:XF (match_operand:SF 1 "register_operand" "")))
+ (set (match_dup 3) (mult:XF (match_dup 2) (match_dup 2)))
+ (set (match_dup 5) (minus:XF (match_dup 4) (match_dup 3)))
+ (set (match_dup 6) (sqrt:XF (match_dup 5)))
+ (parallel [(set (match_dup 7)
+ (unspec:XF [(match_dup 2) (match_dup 6)]
+ UNSPEC_FPATAN))
+ (clobber (match_scratch:XF 8 ""))])
+ (set (match_operand:SF 0 "register_operand" "")
+ (float_truncate:SF (match_dup 7)))]
+ "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
+ && flag_unsafe_math_optimizations"
+{
+ int i;
+
+ for (i=2; i<8; i++)
+ operands[i] = gen_reg_rtx (XFmode);
+
+ emit_move_insn (operands[4], CONST1_RTX (XFmode)); /* fld1 */
+})
+
+(define_expand "acosxf2"
+ [(set (match_dup 2)
+ (mult:XF (match_operand:XF 1 "register_operand" "")
+ (match_dup 1)))
+ (set (match_dup 4) (minus:XF (match_dup 3) (match_dup 2)))
+ (set (match_dup 5) (sqrt:XF (match_dup 4)))
+ (parallel [(set (match_operand:XF 0 "register_operand" "")
+ (unspec:XF [(match_dup 1) (match_dup 5)]
+ UNSPEC_FPATAN))
+ (clobber (match_scratch:XF 6 ""))])]
+ "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
+ && flag_unsafe_math_optimizations"
+{
+ int i;
+
+ for (i=2; i<6; i++)
+ operands[i] = gen_reg_rtx (XFmode);
+
+ emit_move_insn (operands[3], CONST1_RTX (XFmode)); /* fld1 */
+})
+
(define_insn "*fyl2x_sfxf3"
[(set (match_operand:SF 0 "register_operand" "=f")
(unspec:SF [(match_operand:SF 2 "register_operand" "0")
diff --git a/gcc/genopinit.c b/gcc/genopinit.c
index f817969..95d5310 100644
--- a/gcc/genopinit.c
+++ b/gcc/genopinit.c
@@ -124,7 +124,9 @@ static const char * const optabs[] =
"nearbyint_optab->handlers[$A].insn_code = CODE_FOR_$(nearbyint$a2$)",
"sincos_optab->handlers[$A].insn_code = CODE_FOR_$(sincos$a3$)",
"sin_optab->handlers[$A].insn_code = CODE_FOR_$(sin$a2$)",
+ "asin_optab->handlers[$A].insn_code = CODE_FOR_$(asin$a2$)",
"cos_optab->handlers[$A].insn_code = CODE_FOR_$(cos$a2$)",
+ "acos_optab->handlers[$A].insn_code = CODE_FOR_$(acos$a2$)",
"exp_optab->handlers[$A].insn_code = CODE_FOR_$(exp$a2$)",
"exp10_optab->handlers[$A].insn_code = CODE_FOR_$(exp10$a2$)",
"exp2_optab->handlers[$A].insn_code = CODE_FOR_$(exp2$a2$)",
diff --git a/gcc/optabs.c b/gcc/optabs.c
index e8f4dc0..b32315b 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -5380,7 +5380,9 @@ init_optabs (void)
nearbyint_optab = init_optab (UNKNOWN);
sincos_optab = init_optab (UNKNOWN);
sin_optab = init_optab (UNKNOWN);
+ asin_optab = init_optab (UNKNOWN);
cos_optab = init_optab (UNKNOWN);
+ acos_optab = init_optab (UNKNOWN);
exp_optab = init_optab (UNKNOWN);
exp10_optab = init_optab (UNKNOWN);
exp2_optab = init_optab (UNKNOWN);
diff --git a/gcc/optabs.h b/gcc/optabs.h
index 16caa18..2e0a47a 100644
--- a/gcc/optabs.h
+++ b/gcc/optabs.h
@@ -152,8 +152,12 @@ enum optab_index
OTI_sincos,
/* Sine */
OTI_sin,
+ /* Inverse sine */
+ OTI_asin,
/* Cosine */
OTI_cos,
+ /* Inverse cosine */
+ OTI_acos,
/* Exponential */
OTI_exp,
/* Base-10 Exponential */
@@ -271,7 +275,9 @@ extern GTY(()) optab optab_table[OTI_MAX];
#define sqrt_optab (optab_table[OTI_sqrt])
#define sincos_optab (optab_table[OTI_sincos])
#define sin_optab (optab_table[OTI_sin])
+#define asin_optab (optab_table[OTI_asin])
#define cos_optab (optab_table[OTI_cos])
+#define acos_optab (optab_table[OTI_acos])
#define exp_optab (optab_table[OTI_exp])
#define exp10_optab (optab_table[OTI_exp10])
#define exp2_optab (optab_table[OTI_exp2])
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index af0cb75..c88423e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2004-04-20 Uros Bizjak <uros@kss-loka.si>
+
+ * gcc.dg/builtins-39.c: New test.
+
2004-04-20 Aldy Hernandez <aldyh@redhat.com>
* gcc.dg/vmx/vmx.exp: Change DEFAULT_CFLAGS to DEFAULT_VMXCFLAGS.
diff --git a/gcc/testsuite/gcc.dg/builtins-39.c b/gcc/testsuite/gcc.dg/builtins-39.c
new file mode 100644
index 0000000..6359be2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-39.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Check that asin, asinf, asinl, acos, acosf
+ and acosl built-in functions compile.
+
+ Written by Uros Bizjak, 20th April 2004. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math" } */
+
+extern double asin(double);
+extern double acos(double);
+extern float asinf(float);
+extern float acosf(float);
+extern long double asinl(long double);
+extern long double acosl(long double);
+
+
+double test1(double x)
+{
+ return asin(x);
+}
+
+double test2(double x)
+{
+ return acos(x);
+}
+
+float test1f(float x)
+{
+ return asinf(x);
+}
+
+float test2f(float x)
+{
+ return acosf(x);
+}
+
+long double test1l(long double x)
+{
+ return asinl(x);
+}
+
+long double test2l(long double x)
+{
+ return acosl(x);
+}
+