]> gcc.gnu.org Git - gcc.git/commitdiff
optabs.h (enum optab_index): Add new OTI_exp10 and OTI_exp2.
authorUros Bizjak <uros@kss-loka.si>
Wed, 10 Mar 2004 22:36:22 +0000 (23:36 +0100)
committerRoger Sayle <sayle@gcc.gnu.org>
Wed, 10 Mar 2004 22:36:22 +0000 (22:36 +0000)
2004-03-10  Uros Bizjak  <uros@kss-loka.si>

* optabs.h (enum optab_index): Add new OTI_exp10 and OTI_exp2.
(exp10_optab, exp2_optab): Define corresponding macros.
* optabs.c (init_optabs): Initialize exp10_optab and exp2_optab.
* genopinit.c (optabs): Implement exp10_optab and exp2_optab
using exp10?f2 and exp2?f2 patterns.
* builtins.c (expand_builtin_mathfn): Handle BUILT_IN_EXP10{,F,L}
using exp10_optab, and BUILT_IN_EXP2{,F,L} using exp2_optab.
(expand_builtin): Expand BUILT_IN_EXP10{,F,L} and BUILT_IN_EXP2{,F,L}
using expand_builtin_mathfn if flag_unsafe_math_optimizations is set.

* config/i386/i386.md (exp10sf2, exp10df2, exp10xf2, exp2sf2,
exp2df2, exp2xf2): New patterns to implement exp10, exp10f, exp10l,
exp2, exp2f and exp2l built-ins as inline x87 intrinsics.

* gcc.dg/builtins-34.c: New test.

From-SVN: r79279

gcc/ChangeLog
gcc/builtins.c
gcc/config/i386/i386.md
gcc/genopinit.c
gcc/optabs.c
gcc/optabs.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-34.c [new file with mode: 0644]

index a64ba71aa2106883d8f24cf27becd1e61d07d515..0f3c63e46e5329a1014b96c7e0802f618bc6e780 100644 (file)
@@ -1,3 +1,19 @@
+2004-03-10  Uros Bizjak  <uros@kss-loka.si>
+
+       * optabs.h (enum optab_index): Add new OTI_exp10 and OTI_exp2.
+       (exp10_optab, exp2_optab): Define corresponding macros.
+       * optabs.c (init_optabs): Initialize exp10_optab and exp2_optab.
+       * genopinit.c (optabs): Implement exp10_optab and exp2_optab
+       using exp10?f2 and exp2?f2 patterns.
+       * builtins.c (expand_builtin_mathfn): Handle BUILT_IN_EXP10{,F,L}
+       using exp10_optab, and BUILT_IN_EXP2{,F,L} using exp2_optab.
+       (expand_builtin): Expand BUILT_IN_EXP10{,F,L} and BUILT_IN_EXP2{,F,L}
+       using expand_builtin_mathfn if flag_unsafe_math_optimizations is set.
+
+       * config/i386/i386.md (exp10sf2, exp10df2, exp10xf2, exp2sf2,
+       exp2df2, exp2xf2): New patterns to implement exp10, exp10f, exp10l,
+       exp2, exp2f and exp2l built-ins as inline x87 intrinsics.
+
 2004-03-10  Anthony Green  <green@redhat.com>
 
        * doc/invoke.texi (ARM Options): Fix -mpfu typo.
index 1eeedd254bc9c5019bdb1360f21078d88a0dbf86..daf06e8fc3ed1e6687b2424efe8648af8b9c06fa 100644 (file)
@@ -1629,6 +1629,14 @@ expand_builtin_mathfn (tree exp, rtx target, rtx subtarget)
     case BUILT_IN_EXPF:
     case BUILT_IN_EXPL:
       errno_set = true; builtin_optab = exp_optab; break;
+    case BUILT_IN_EXP10:
+    case BUILT_IN_EXP10F:
+    case BUILT_IN_EXP10L:
+      errno_set = true; builtin_optab = exp10_optab; break;
+    case BUILT_IN_EXP2:
+    case BUILT_IN_EXP2F:
+    case BUILT_IN_EXP2L:
+      errno_set = true; builtin_optab = exp2_optab; break;
     case BUILT_IN_LOG:
     case BUILT_IN_LOGF:
     case BUILT_IN_LOGL:
@@ -5107,6 +5115,12 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
     case BUILT_IN_EXP:
     case BUILT_IN_EXPF:
     case BUILT_IN_EXPL:
+    case BUILT_IN_EXP10:
+    case BUILT_IN_EXP10F:
+    case BUILT_IN_EXP10L:
+    case BUILT_IN_EXP2:
+    case BUILT_IN_EXP2F:
+    case BUILT_IN_EXP2L:
     case BUILT_IN_LOG:
     case BUILT_IN_LOGF:
     case BUILT_IN_LOGL:
index 2bee3576f3f38e1bac42a6d7cfed7a15b460e9cb..c9e7c8caa52af1be25abfd4549dea5510e543be4 100644 (file)
    (set (match_dup 4) (mult:XF (match_dup 2) (match_dup 3)))
    (set (match_dup 5) (unspec:XF [(match_dup 4)] UNSPEC_FRNDINT))
    (set (match_dup 6) (minus:XF (match_dup 4) (match_dup 5)))
+
    (set (match_dup 7) (unspec:XF [(match_dup 6)] UNSPEC_F2XM1))
    (set (match_dup 9) (plus:XF (match_dup 7) (match_dup 8)))
    (parallel [(set (match_operand:DF 0 "register_operand" "")
   emit_move_insn (operands[7], CONST1_RTX (XFmode));  /* fld1 */
 })
 
+(define_expand "exp10sf2"
+  [(set (match_dup 2)
+       (float_extend:XF (match_operand:SF 1 "register_operand" "")))
+   (set (match_dup 4) (mult:XF (match_dup 2) (match_dup 3)))
+   (set (match_dup 5) (unspec:XF [(match_dup 4)] UNSPEC_FRNDINT))
+   (set (match_dup 6) (minus:XF (match_dup 4) (match_dup 5)))
+   (set (match_dup 7) (unspec:XF [(match_dup 6)] UNSPEC_F2XM1))
+   (set (match_dup 9) (plus:XF (match_dup 7) (match_dup 8)))
+   (parallel [(set (match_operand:SF 0 "register_operand" "")
+                  (unspec:SF [(match_dup 9) (match_dup 5)] UNSPEC_FSCALE))
+             (clobber (match_scratch:SF 5 ""))])]
+  "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
+   && flag_unsafe_math_optimizations"
+{
+  rtx temp;
+  int i;
+
+  for (i=2; i<10; i++)
+    operands[i] = gen_reg_rtx (XFmode);
+  temp = standard_80387_constant_rtx (6); /* fldl2t */
+  emit_move_insn (operands[3], temp);
+  emit_move_insn (operands[8], CONST1_RTX (XFmode));  /* fld1 */
+})
+
+(define_expand "exp10df2"
+  [(set (match_dup 2)
+       (float_extend:XF (match_operand:DF 1 "register_operand" "")))
+   (set (match_dup 4) (mult:XF (match_dup 2) (match_dup 3)))
+   (set (match_dup 5) (unspec:XF [(match_dup 4)] UNSPEC_FRNDINT))
+   (set (match_dup 6) (minus:XF (match_dup 4) (match_dup 5)))
+   (set (match_dup 7) (unspec:XF [(match_dup 6)] UNSPEC_F2XM1))
+   (set (match_dup 9) (plus:XF (match_dup 7) (match_dup 8)))
+   (parallel [(set (match_operand:DF 0 "register_operand" "")
+                  (unspec:DF [(match_dup 9) (match_dup 5)] UNSPEC_FSCALE))
+             (clobber (match_scratch:DF 5 ""))])]
+  "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
+   && flag_unsafe_math_optimizations"
+{
+  rtx temp;
+  int i;
+
+  for (i=2; i<10; i++)
+    operands[i] = gen_reg_rtx (XFmode);
+  temp = standard_80387_constant_rtx (6); /* fldl2t */
+  emit_move_insn (operands[3], temp);
+  emit_move_insn (operands[8], CONST1_RTX (XFmode));  /* fld1 */
+})
+
+(define_expand "exp10xf2"
+  [(set (match_dup 3) (mult:XF (match_operand:XF 1 "register_operand" "")
+                              (match_dup 2)))
+   (set (match_dup 4) (unspec:XF [(match_dup 3)] UNSPEC_FRNDINT))
+   (set (match_dup 5) (minus:XF (match_dup 3) (match_dup 4)))
+   (set (match_dup 6) (unspec:XF [(match_dup 5)] UNSPEC_F2XM1))
+   (set (match_dup 8) (plus:XF (match_dup 6) (match_dup 7)))
+   (parallel [(set (match_operand:XF 0 "register_operand" "")
+                  (unspec:XF [(match_dup 8) (match_dup 4)] UNSPEC_FSCALE))
+             (clobber (match_scratch:XF 5 ""))])]
+  "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
+   && flag_unsafe_math_optimizations"
+{
+  rtx temp;
+  int i;
+
+  for (i=2; i<9; i++)
+    operands[i] = gen_reg_rtx (XFmode);
+  temp = standard_80387_constant_rtx (6); /* fldl2t */
+  emit_move_insn (operands[2], temp);
+  emit_move_insn (operands[7], CONST1_RTX (XFmode));  /* fld1 */
+})
+
+(define_expand "exp2sf2"
+  [(set (match_dup 2)
+       (float_extend:XF (match_operand:SF 1 "register_operand" "")))
+   (set (match_dup 3) (unspec:XF [(match_dup 2)] UNSPEC_FRNDINT))
+   (set (match_dup 4) (minus:XF (match_dup 2) (match_dup 3)))
+   (set (match_dup 5) (unspec:XF [(match_dup 4)] UNSPEC_F2XM1))
+   (set (match_dup 7) (plus:XF (match_dup 5) (match_dup 6)))
+   (parallel [(set (match_operand:SF 0 "register_operand" "")
+                  (unspec:SF [(match_dup 7) (match_dup 3)] UNSPEC_FSCALE))
+             (clobber (match_scratch:SF 3 ""))])]
+  "! 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[6], CONST1_RTX (XFmode));  /* fld1 */
+})
+
+(define_expand "exp2df2"
+  [(set (match_dup 2)
+       (float_extend:XF (match_operand:DF 1 "register_operand" "")))
+   (set (match_dup 3) (unspec:XF [(match_dup 2)] UNSPEC_FRNDINT))
+   (set (match_dup 4) (minus:XF (match_dup 2) (match_dup 3)))
+   (set (match_dup 5) (unspec:XF [(match_dup 4)] UNSPEC_F2XM1))
+   (set (match_dup 7) (plus:XF (match_dup 5) (match_dup 6)))
+   (parallel [(set (match_operand:DF 0 "register_operand" "")
+                  (unspec:DF [(match_dup 7) (match_dup 3)] UNSPEC_FSCALE))
+             (clobber (match_scratch:DF 3 ""))])]
+  "! 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[6], CONST1_RTX (XFmode));  /* fld1 */
+})
+
+(define_expand "exp2xf2"
+  [(set (match_dup 2) (match_operand:XF 1 "register_operand" ""))
+   (set (match_dup 3) (unspec:XF [(match_dup 2)] UNSPEC_FRNDINT))
+   (set (match_dup 4) (minus:XF (match_dup 2) (match_dup 3)))
+   (set (match_dup 5) (unspec:XF [(match_dup 4)] UNSPEC_F2XM1))
+   (set (match_dup 7) (plus:XF (match_dup 5) (match_dup 6)))
+   (parallel [(set (match_operand:XF 0 "register_operand" "")
+                  (unspec:XF [(match_dup 7) (match_dup 3)] UNSPEC_FSCALE))
+             (clobber (match_scratch:XF 3 ""))])]
+  "! 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[6], CONST1_RTX (XFmode));  /* fld1 */
+})
+
 (define_expand "atansf2"
   [(parallel [(set (match_operand:SF 0 "register_operand" "")
                   (unspec:SF [(match_dup 2)
index 52a224e6d538049f635cec6d3dfa2bf026897206..b3b651821c0b96dcd520cf3661f0ddd2bba08d19 100644 (file)
@@ -125,6 +125,8 @@ static const char * const optabs[] =
   "sin_optab->handlers[$A].insn_code = CODE_FOR_$(sin$a2$)",
   "cos_optab->handlers[$A].insn_code = CODE_FOR_$(cos$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$)",
   "log_optab->handlers[$A].insn_code = CODE_FOR_$(log$a2$)",
   "log10_optab->handlers[$A].insn_code = CODE_FOR_$(log10$a2$)",  
   "log2_optab->handlers[$A].insn_code = CODE_FOR_$(log2$a2$)",  
index 4fd6ae6aa1e5381ce7a8e3480a22be167c642fb9..b9439a7dcd631a30b55797d99864e866bb16074e 100644 (file)
@@ -5274,6 +5274,8 @@ init_optabs (void)
   sin_optab = init_optab (UNKNOWN);
   cos_optab = init_optab (UNKNOWN);
   exp_optab = init_optab (UNKNOWN);
+  exp10_optab = init_optab (UNKNOWN);
+  exp2_optab = init_optab (UNKNOWN);
   log_optab = init_optab (UNKNOWN);
   log10_optab = init_optab (UNKNOWN);
   log2_optab = init_optab (UNKNOWN);
index 496ba1a6fc8e21a41a2beb034a726df1b160941f..765e169cb4650b3b11c2afbddb7252b2db33a94f 100644 (file)
@@ -154,6 +154,10 @@ enum optab_index
   OTI_cos,
   /* Exponential */
   OTI_exp,
+  /* Base-10 Exponential */
+  OTI_exp10,
+  /* Base-2 Exponential */
+  OTI_exp2,
   /* Natural Logarithm */
   OTI_log,
   /* Base-10 Logarithm */
@@ -263,6 +267,8 @@ extern GTY(()) optab optab_table[OTI_MAX];
 #define sin_optab (optab_table[OTI_sin])
 #define cos_optab (optab_table[OTI_cos])
 #define exp_optab (optab_table[OTI_exp])
+#define exp10_optab (optab_table[OTI_exp10])
+#define exp2_optab (optab_table[OTI_exp2])
 #define log_optab (optab_table[OTI_log])
 #define log10_optab (optab_table[OTI_log10])
 #define log2_optab (optab_table[OTI_log2])
index b2aef9c75e25d4ef6795de6d37d4881d290468c7..21b2f0583dda9d14b74aa25e42675835603d91fe 100644 (file)
@@ -1,3 +1,7 @@
+2004-03-10  Uros Bizjak  <uros@kss-loka.si>
+
+       * gcc.dg/builtins-34.c: New test.
+
 2004-03-10  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/torture/builtin-nonneg-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/builtins-34.c b/gcc/testsuite/gcc.dg/builtins-34.c
new file mode 100644 (file)
index 0000000..fb6062b
--- /dev/null
@@ -0,0 +1,48 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+   Check that exp10, exp10f, exp10l, exp2, exp2f and exp2l
+   built-in functions compile.
+
+   Written by Uros Bizjak, 13th February 2004.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math" } */
+
+extern double exp10(double);
+extern double exp2(double);
+extern float exp10f(float);
+extern float exp2f(float);
+extern long double exp10l(long double);
+extern long double exp2l(long double);
+
+
+double test1(double x)
+{
+  return exp10(x);
+}
+
+double test2(double x)
+{
+  return exp2(x);
+}
+
+float test1f(float x)
+{
+  return exp10f(x);
+}
+
+float test2f(float x)
+{
+  return exp2f(x);
+}
+
+long double test1l(long double x)
+{
+  return exp10l(x);
+}
+
+long double test2l(long double x)
+{
+  return exp2l(x);
+}
+
This page took 0.119223 seconds and 5 git commands to generate.