OSDN Git Service

* optabs.h (enum optab_index): Add new OTI_significand.
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Jun 2009 14:22:16 +0000 (14:22 +0000)
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Jun 2009 14:22:16 +0000 (14:22 +0000)
(significand_optab): Define corresponding macro.
* optabs.c (init_optabs): Initialize significand_optab.
* genopinit.c (optabs): Implement significand_optab using
significand?f2 patterns.
* builtins.c (expand_builtin_mathfn): Handle
BUILT_IN_SIGNIFICAND{,F,L}.
(expand_builtin): Expand BUILT_IN_SIGNIFICAND{,F,L} using
expand_builtin_mathfn if flag_unsafe_math_optimizations is set.

* config/i386/i386.md (significandxf2, significand<mode>2): New
expanders to implement significandf, significand and significandl
built-ins as inline x87 intrinsics.

testsuite/ChangeLog:

* gcc.dg/builtins-34.c: Add significand cases.

PR testsuite/40491
* testsuite/gcc.dg/20080522-1.c: Remove testcase for real.
* testsuite/gcc.dg/20080528-1.c: Ditto.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148705 138bc75d-0d04-0410-961f-82ee72b054a4

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/20080522-1.c [deleted file]
gcc/testsuite/gcc.dg/20080528-1.c [deleted file]
gcc/testsuite/gcc.dg/builtins-34.c

index 0ee4914..4bd4664 100644 (file)
@@ -1,3 +1,19 @@
+2009-06-19  Uros Bizjak  <ubizjak@gmail.com>
+
+       * optabs.h (enum optab_index): Add new OTI_significand.
+       (significand_optab): Define corresponding macro.
+       * optabs.c (init_optabs): Initialize significand_optab.
+       * genopinit.c (optabs): Implement significand_optab using
+       significand?f2 patterns.
+       * builtins.c (expand_builtin_mathfn): Handle
+       BUILT_IN_SIGNIFICAND{,F,L}.
+       (expand_builtin): Expand BUILT_IN_SIGNIFICAND{,F,L} using
+       expand_builtin_mathfn if flag_unsafe_math_optimizations is set.
+
+       * config/i386/i386.md (significandxf2, significand<mode>2): New
+       expanders to implement significandf, significand and significandl
+       built-ins as inline x87 intrinsics.
+
 2009-06-18  Anatoly Sokolov  <aesok@post.ru>
 
        * config/avr/avr.c (avr_override_options): Remove setting value of
@@ -42,8 +58,6 @@
        * timevar.def (TV_SEE): Remove.
        * tree-pass.h (pass_see): Remove declaration.
        * doc/invoke.texi (-fsee): Remove documentation.
-       * testsuite/gcc.dg/20080522-1.c: Remove testcase.
-       * testsuite/gcc.dg/20080528-1.c: Remove testcase.
        
 2009-06-18  Martin Jambor  <mjambor@suse.cz>
 
        * config/rs6000/crtsavgpr.asm: Likewise.
        * config/rs6000/crtsavfpr.asm: Likewise.
 
-       * dwarf2out.c (output_cfi_directive): Pass 1 instead of
-       0 to second argument of DWARF2_FRAME_REG_OUT macros.
+       * dwarf2out.c (output_cfi_directive): Pass 1 instead of 0 to second
+       argument of DWARF2_FRAME_REG_OUT macros.
 
 2009-06-03  Julian Brown  <julian@codesourcery.com>
 
index a6d26ef..e906ef7 100644 (file)
@@ -1975,6 +1975,8 @@ expand_builtin_mathfn (tree exp, rtx target, rtx subtarget)
       /* Else fallthrough and expand as rint.  */
     CASE_FLT_FN (BUILT_IN_RINT):
       builtin_optab = rint_optab; break;
+    CASE_FLT_FN (BUILT_IN_SIGNIFICAND):
+      builtin_optab = significand_optab; break;
     default:
       gcc_unreachable ();
     }
@@ -6332,6 +6334,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
     CASE_FLT_FN (BUILT_IN_ASIN):
     CASE_FLT_FN (BUILT_IN_ACOS):
     CASE_FLT_FN (BUILT_IN_ATAN):
+    CASE_FLT_FN (BUILT_IN_SIGNIFICAND):
       /* Treat these like sqrt only if unsafe math optimizations are allowed,
         because of possible accuracy problems.  */
       if (! flag_unsafe_math_optimizations)
index 59d9e82..a71ca43 100644 (file)
 (define_expand "scalb<mode>3"
   [(use (match_operand:MODEF 0 "register_operand" ""))
    (use (match_operand:MODEF 1 "general_operand" ""))
-   (use (match_operand:MODEF 2 "register_operand" ""))]
+   (use (match_operand:MODEF 2 "general_operand" ""))]
  "TARGET_USE_FANCY_MATH_387
    && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
        || TARGET_MIX_SSE_I387)
   emit_insn (gen_truncxf<mode>2_i387_noop (operands[0], op0));
   DONE;
 })
+
+(define_expand "significandxf2"
+  [(parallel [(set (match_operand:XF 0 "register_operand" "")
+                  (unspec:XF [(match_operand:XF 1 "register_operand" "")]
+                             UNSPEC_XTRACT_FRACT))
+             (set (match_dup 2)
+                  (unspec:XF [(match_dup 1)] UNSPEC_XTRACT_EXP))])]
+  "TARGET_USE_FANCY_MATH_387
+   && flag_unsafe_math_optimizations"
+{
+  operands[2] = gen_reg_rtx (XFmode);
+})
+
+(define_expand "significand<mode>2"
+  [(use (match_operand:MODEF 0 "register_operand" ""))
+   (use (match_operand:MODEF 1 "register_operand" ""))]
+  "TARGET_USE_FANCY_MATH_387
+   && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
+       || TARGET_MIX_SSE_I387)
+   && flag_unsafe_math_optimizations"
+{
+  rtx op0 = gen_reg_rtx (XFmode);
+  rtx op1 = gen_reg_rtx (XFmode);
+
+  emit_insn (gen_fxtract_extend<mode>xf3_i387 (op0, op1, operands[1]));
+  emit_insn (gen_truncxf<mode>2_i387_noop (operands[0], op0));
+  DONE;
+})
 \f
 
 (define_insn "sse4_1_round<mode>2"
index f8cbf95..52e0dd9 100644 (file)
@@ -178,6 +178,7 @@ static const char * const optabs[] =
   "optab_handler (expm1_optab, $A)->insn_code = CODE_FOR_$(expm1$a2$)",
   "optab_handler (ldexp_optab, $A)->insn_code = CODE_FOR_$(ldexp$a3$)",
   "optab_handler (scalb_optab, $A)->insn_code = CODE_FOR_$(scalb$a3$)",
+  "optab_handler (significand_optab, $A)->insn_code = CODE_FOR_$(significand$a2$)",
   "optab_handler (logb_optab, $A)->insn_code = CODE_FOR_$(logb$a2$)",
   "optab_handler (ilogb_optab, $A)->insn_code = CODE_FOR_$(ilogb$a2$)",
   "optab_handler (log_optab, $A)->insn_code = CODE_FOR_$(log$a2$)",
index 99da304..34d284a 100644 (file)
@@ -6271,6 +6271,7 @@ init_optabs (void)
   init_optab (expm1_optab, UNKNOWN);
   init_optab (ldexp_optab, UNKNOWN);
   init_optab (scalb_optab, UNKNOWN);
+  init_optab (significand_optab, UNKNOWN);
   init_optab (logb_optab, UNKNOWN);
   init_optab (ilogb_optab, UNKNOWN);
   init_optab (log_optab, UNKNOWN);
index 096feda..82f8084 100644 (file)
@@ -242,6 +242,8 @@ enum optab_index
   OTI_ldexp,
   /* Multiply floating-point number by integral power of radix */
   OTI_scalb,
+  /* Mantissa of a floating-point number */
+  OTI_significand,
   /* Radix-independent exponent */
   OTI_logb,
   OTI_ilogb,
@@ -462,6 +464,7 @@ extern struct optab_d optab_table[OTI_MAX];
 #define expm1_optab (&optab_table[OTI_expm1])
 #define ldexp_optab (&optab_table[OTI_ldexp])
 #define scalb_optab (&optab_table[OTI_scalb])
+#define significand_optab (&optab_table[OTI_significand])
 #define logb_optab (&optab_table[OTI_logb])
 #define ilogb_optab (&optab_table[OTI_ilogb])
 #define log_optab (&optab_table[OTI_log])
index 7ddc758..918d198 100644 (file)
@@ -1,3 +1,13 @@
+2009-06-19  Uros Bizjak  <ubizjak@gmail.com>
+
+       * gcc.dg/builtins-34.c: Add significand cases.
+
+2009-06-19  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR testsuite/40491
+       * testsuite/gcc.dg/20080522-1.c: Remove testcase for real.
+       * testsuite/gcc.dg/20080528-1.c: Ditto.
+
 2009-06-19  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/40450
diff --git a/gcc/testsuite/gcc.dg/20080522-1.c b/gcc/testsuite/gcc.dg/20080522-1.c
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/gcc/testsuite/gcc.dg/20080528-1.c b/gcc/testsuite/gcc.dg/20080528-1.c
deleted file mode 100644 (file)
index e69de29..0000000
index ee8d751..e348a1c 100644 (file)
@@ -1,7 +1,6 @@
 /* Copyright (C) 2004 Free Software Foundation.
 
-   Check that exp10, exp10f, exp10l, exp2, exp2f, exp2l, pow10, pow10f,
-   pow10l, expm1, expm1f and expm1l built-in functions compile.
+   Check that various built-in functions compile.
 
    Written by Uros Bizjak, 13th February 2004.  */
 
@@ -16,6 +15,7 @@ extern double ldexp(double, int);
 extern double scalb(double, double);
 extern double scalbn(double, int);
 extern double scalbln(double, long);
+extern double significand(double);
 extern float exp10f(float);
 extern float exp2f(float);
 extern float pow10f(float);
@@ -24,6 +24,7 @@ extern float ldexpf(float, int);
 extern float scalbf(float, float);
 extern float scalbnf(float, int);
 extern float scalblnf(float, long);
+extern float significandf(float);
 extern long double exp10l(long double);
 extern long double exp2l(long double);
 extern long double pow10l(long double);
@@ -32,6 +33,7 @@ extern long double ldexpl(long double, int);
 extern long double scalbl(long double, long double);
 extern long double scalbnl(long double, int);
 extern long double scalblnl(long double, long);
+extern long double significandl(long double);
 
 
 double test1(double x)
@@ -74,6 +76,11 @@ double test8(double x, long exp)
   return scalbln(x, exp);
 }
 
+double test9(double x)
+{
+  return significand(x);
+}
+
 float test1f(float x)
 {
   return exp10f(x);
@@ -114,6 +121,11 @@ float test8f(float x, long exp)
   return scalblnf(x, exp);
 }
 
+float test9f(float x)
+{
+  return significandf(x);
+}
+
 long double test1l(long double x)
 {
   return exp10l(x);
@@ -153,3 +165,8 @@ long double test8l(long double x, long exp)
 {
   return scalblnl(x, exp);
 }
+
+long double test9l(long double x)
+{
+  return significandl(x);
+}