]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
optabs.h (enum optab_index): Rename OTI_drem to OTI_remainder.
authorUros Bizjak <uros@kss-loka.si>
Wed, 25 Oct 2006 06:36:49 +0000 (08:36 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Wed, 25 Oct 2006 06:36:49 +0000 (08:36 +0200)
        * optabs.h (enum optab_index): Rename OTI_drem to OTI_remainder.
        (remainder_optab): Define corresponding macro.
        (drem_optab): Remove.
        * optabs.c (init_optabs): Initialize remainder_optab.  Remove
        drem_optab initialization.
        * genopinit.c (optabs): Implement remainder_optab using
        remainder?f3 patterns.  Remove drem_optab.
        * builtins.c (expand_builtin_mathfn_2): Handle
        BUILT_IN_REMAINDER{,F,L} using remainder_optab.
        (expand_builtin): Expand BUILT_IN_REMAINDER{,F,L} using
        expand_builtin_mathfn_2.

        (expand_builtin) [BUILT_IN_FMOD, BUILT_IN_DREM]: Do not
        depend on flag_unsafe_math_optimizations.

        * config/i386/i386.md ("remaindersf3", "remainderdf3")
        ("remainderxf3"): Renamed from "drem{s,d,x}f3" expanders.
        Do not depend on flag_unsafe_math_optimizations.  Use
        truncxf?f expander instead of truncxf?f_i387_noop.

        ("fpremxf4", "fprem1xf4"): Do not depend on
        flag_unsafe_math_optimizations.
        ("fmodsf3", "fmoddf3", "fmodxf3"): Do not depend on
        flag_unsafe_math_optimizations.  Use truncxf?f expander
        instead of truncxf?f_i387_noop.

        * doc/md.texi (fmod, remainder): Document standard named pattern.

testsuite/ChangeLog:

        * gcc.dg/builtins-40.c: Also check remainder(), remainderf()
        and remainderl() built-in functions.  Remove -ffast-math from
        dg-options.

From-SVN: r118024

gcc/ChangeLog
gcc/builtins.c
gcc/config/i386/i386.md
gcc/doc/md.texi
gcc/genopinit.c
gcc/optabs.c
gcc/optabs.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-40.c

index 829306c861d8cb0d73162de6f4f30b5753c9c8b5..905863120330910345d3f9952b726357a4bede5f 100644 (file)
@@ -1,3 +1,33 @@
+2006-10-25  Uros Bizjak  <uros@kss-loka.si>
+
+       * optabs.h (enum optab_index): Rename OTI_drem to OTI_remainder.
+       (remainder_optab): Define corresponding macro.
+       (drem_optab): Remove.
+       * optabs.c (init_optabs): Initialize remainder_optab.  Remove
+       drem_optab initialization.
+       * genopinit.c (optabs): Implement remainder_optab using
+       remainder?f3 patterns.  Remove drem_optab.
+       * builtins.c (expand_builtin_mathfn_2): Handle
+       BUILT_IN_REMAINDER{,F,L} using remainder_optab.
+       (expand_builtin): Expand BUILT_IN_REMAINDER{,F,L} using
+       expand_builtin_mathfn_2.
+
+       (expand_builtin) [BUILT_IN_FMOD, BUILT_IN_DREM]: Do not
+       depend on flag_unsafe_math_optimizations.
+
+       * config/i386/i386.md ("remaindersf3", "remainderdf3")
+       ("remainderxf3"): Renamed from "drem{s,d,x}f3" expanders.
+       Do not depend on flag_unsafe_math_optimizations.  Use
+       truncxf?f expander instead of truncxf?f_i387_noop.
+
+       ("fpremxf4", "fprem1xf4"): Do not depend on
+       flag_unsafe_math_optimizations.
+       ("fmodsf3", "fmoddf3", "fmodxf3"): Do not depend on
+       flag_unsafe_math_optimizations.  Use truncxf?f expander
+       instead of truncxf?f_i387_noop.
+
+       * doc/md.texi (fmod, remainder): Document standard named pattern.
+
 2006-10-24  Richard Sandiford  <richard@codesourcery.com>
            David Daney  <ddaney@avtrex.com>
 
index ebb9a857629279099316bdb3289b818baa8aee77..6955cda2a834b4dc5990b5c6ed92ac46fe5a8645 100644 (file)
@@ -1975,8 +1975,9 @@ expand_builtin_mathfn_2 (tree exp, rtx target, rtx subtarget)
       builtin_optab = ldexp_optab; break;
     CASE_FLT_FN (BUILT_IN_FMOD):
       builtin_optab = fmod_optab; break;
+    CASE_FLT_FN (BUILT_IN_REMAINDER):
     CASE_FLT_FN (BUILT_IN_DREM):
-      builtin_optab = drem_optab; break;
+      builtin_optab = remainder_optab; break;
     default:
       gcc_unreachable ();
     }
@@ -5796,10 +5797,12 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
 
     CASE_FLT_FN (BUILT_IN_ATAN2):
     CASE_FLT_FN (BUILT_IN_LDEXP):
-    CASE_FLT_FN (BUILT_IN_FMOD):
-    CASE_FLT_FN (BUILT_IN_DREM):
       if (! flag_unsafe_math_optimizations)
        break;
+
+    CASE_FLT_FN (BUILT_IN_FMOD):
+    CASE_FLT_FN (BUILT_IN_REMAINDER):
+    CASE_FLT_FN (BUILT_IN_DREM):
       target = expand_builtin_mathfn_2 (exp, target, subtarget);
       if (target)
        return target;
index ac26aabd0f9136aa27686bf0735af121b4b52983..aadf2ff8f85f60a2a4910ed5a035e14a59aceac8 100644 (file)
                   UNSPEC_FPREM_U))
    (set (reg:CCFP FPSR_REG)
        (unspec:CCFP [(const_int 0)] UNSPEC_NOP))]
-  "TARGET_USE_FANCY_MATH_387
-   && flag_unsafe_math_optimizations"
+  "TARGET_USE_FANCY_MATH_387"
   "fprem"
   [(set_attr "type" "fpspc")
    (set_attr "mode" "XF")])
    (use (match_operand:SF 1 "register_operand" ""))
    (use (match_operand:SF 2 "register_operand" ""))]
   "TARGET_USE_FANCY_MATH_387
-   && (!TARGET_SSE_MATH || TARGET_MIX_SSE_I387)
-   && flag_unsafe_math_optimizations"
+   && (!TARGET_SSE_MATH || TARGET_MIX_SSE_I387)"
 {
   rtx label = gen_label_rtx ();
 
   emit_insn (gen_fpremxf4 (op1, op2, op1, op2));
   ix86_emit_fp_unordered_jump (label);
 
-  emit_insn (gen_truncxfsf2_i387_noop (operands[0], op1));
+  emit_insn (gen_truncxfsf2 (operands[0], op1));
   DONE;
 })
 
    (use (match_operand:DF 1 "register_operand" ""))
    (use (match_operand:DF 2 "register_operand" ""))]
   "TARGET_USE_FANCY_MATH_387
-   && (!(TARGET_SSE2 && TARGET_SSE_MATH) || TARGET_MIX_SSE_I387)
-   && flag_unsafe_math_optimizations"
+   && (!(TARGET_SSE2 && TARGET_SSE_MATH) || TARGET_MIX_SSE_I387)"
 {
   rtx label = gen_label_rtx ();
 
   emit_insn (gen_fpremxf4 (op1, op2, op1, op2));
   ix86_emit_fp_unordered_jump (label);
 
-  emit_insn (gen_truncxfdf2_i387_noop (operands[0], op1));
+  emit_insn (gen_truncxfdf2 (operands[0], op1));
   DONE;
 })
 
   [(use (match_operand:XF 0 "register_operand" ""))
    (use (match_operand:XF 1 "register_operand" ""))
    (use (match_operand:XF 2 "register_operand" ""))]
-  "TARGET_USE_FANCY_MATH_387
-   && flag_unsafe_math_optimizations"
+  "TARGET_USE_FANCY_MATH_387"
 {
   rtx label = gen_label_rtx ();
 
                   UNSPEC_FPREM1_U))
    (set (reg:CCFP FPSR_REG)
        (unspec:CCFP [(const_int 0)] UNSPEC_NOP))]
-  "TARGET_USE_FANCY_MATH_387
-   && flag_unsafe_math_optimizations"
+  "TARGET_USE_FANCY_MATH_387"
   "fprem1"
   [(set_attr "type" "fpspc")
    (set_attr "mode" "XF")])
 
-(define_expand "dremsf3"
+(define_expand "remaindersf3"
   [(use (match_operand:SF 0 "register_operand" ""))
    (use (match_operand:SF 1 "register_operand" ""))
    (use (match_operand:SF 2 "register_operand" ""))]
   "TARGET_USE_FANCY_MATH_387
-   && (!TARGET_SSE_MATH || TARGET_MIX_SSE_I387)
-   && flag_unsafe_math_optimizations"
+   && (!TARGET_SSE_MATH || TARGET_MIX_SSE_I387)"
 {
   rtx label = gen_label_rtx ();
 
   emit_insn (gen_fprem1xf4 (op1, op2, op1, op2));
   ix86_emit_fp_unordered_jump (label);
 
-  emit_insn (gen_truncxfsf2_i387_noop (operands[0], op1));
+  emit_insn (gen_truncxfsf2 (operands[0], op1));
   DONE;
 })
 
-(define_expand "dremdf3"
+(define_expand "remainderdf3"
   [(use (match_operand:DF 0 "register_operand" ""))
    (use (match_operand:DF 1 "register_operand" ""))
    (use (match_operand:DF 2 "register_operand" ""))]
   "TARGET_USE_FANCY_MATH_387
-   && (!(TARGET_SSE2 && TARGET_SSE_MATH) || TARGET_MIX_SSE_I387)
-   && flag_unsafe_math_optimizations"
+   && (!(TARGET_SSE2 && TARGET_SSE_MATH) || TARGET_MIX_SSE_I387)"
 {
   rtx label = gen_label_rtx ();
 
   emit_insn (gen_fprem1xf4 (op1, op2, op1, op2));
   ix86_emit_fp_unordered_jump (label);
 
-  emit_insn (gen_truncxfdf2_i387_noop (operands[0], op1));
+  emit_insn (gen_truncxfdf2 (operands[0], op1));
   DONE;
 })
 
-(define_expand "dremxf3"
+(define_expand "remainderxf3"
   [(use (match_operand:XF 0 "register_operand" ""))
    (use (match_operand:XF 1 "register_operand" ""))
    (use (match_operand:XF 2 "register_operand" ""))]
-  "TARGET_USE_FANCY_MATH_387
-   && flag_unsafe_math_optimizations"
+  "TARGET_USE_FANCY_MATH_387"
 {
   rtx label = gen_label_rtx ();
 
index 3b30e361e30b3762ad9bde4af2ab00c65a2fb12e..a05f9d04a9ead5e3129be51764869620f480ea07 100644 (file)
@@ -3569,6 +3569,26 @@ corresponds to the C data type @code{double} and the @code{sqrtf}
 built-in function uses the mode which corresponds to the C data
 type @code{float}.
 
+@cindex @code{fmod@var{m}3} instruction pattern
+@item @samp{fmod@var{m}3}
+Store the remainder of dividing operand 1 by operand 2 into
+operand 0, rounded towards zero to an integer.
+
+The @code{fmod} built-in function of C always uses the mode which
+corresponds to the C data type @code{double} and the @code{fmodf}
+built-in function uses the mode which corresponds to the C data
+type @code{float}.
+
+@cindex @code{remainder@var{m}3} instruction pattern
+@item @samp{remainder@var{m}3}
+Store the remainder of dividing operand 1 by operand 2 into
+operand 0, rounded to the nearest integer.
+
+The @code{remainder} built-in function of C always uses the mode
+which corresponds to the C data type @code{double} and the
+@code{remainderf} built-in function uses the mode which corresponds
+to the C data type @code{float}.
+
 @cindex @code{cos@var{m}2} instruction pattern
 @item @samp{cos@var{m}2}
 Store the cosine of operand 1 into operand 0.
index c9cea085852a08372ed373709ec1d084d0c24148..4f7bd46595c24eda7ead0cc26cd9a65a00e1b13a 100644 (file)
@@ -93,7 +93,7 @@ static const char * const optabs[] =
   "smod_optab->handlers[$A].insn_code = CODE_FOR_$(mod$a3$)",
   "umod_optab->handlers[$A].insn_code = CODE_FOR_$(umod$a3$)",
   "fmod_optab->handlers[$A].insn_code = CODE_FOR_$(fmod$a3$)",
-  "drem_optab->handlers[$A].insn_code = CODE_FOR_$(drem$a3$)",
+  "remainder_optab->handlers[$A].insn_code = CODE_FOR_$(remainder$a3$)",
   "ftrunc_optab->handlers[$A].insn_code = CODE_FOR_$(ftrunc$F$a2$)",
   "and_optab->handlers[$A].insn_code = CODE_FOR_$(and$a3$)",
   "ior_optab->handlers[$A].insn_code = CODE_FOR_$(ior$a3$)",
index fe7ae065962835080c1af5ba57b1e698ecb1740d..12fd34e5da21de2c9a2afc74eed909c0069423f9 100644 (file)
@@ -5212,7 +5212,7 @@ init_optabs (void)
   smod_optab = init_optab (MOD);
   umod_optab = init_optab (UMOD);
   fmod_optab = init_optab (UNKNOWN);
-  drem_optab = init_optab (UNKNOWN);
+  remainder_optab = init_optab (UNKNOWN);
   ftrunc_optab = init_optab (UNKNOWN);
   and_optab = init_optab (AND);
   ior_optab = init_optab (IOR);
index 58fb6905175c54a846f9086739489be4958e5806..69dcbe11b91ec84c91bc631ca0d8c10bb354815b 100644 (file)
@@ -98,7 +98,7 @@ enum optab_index
   OTI_umod,
   /* Floating point remainder functions */
   OTI_fmod,
-  OTI_drem,
+  OTI_remainder,
   /* Convert float to integer in float fmt */
   OTI_ftrunc,
 
@@ -289,7 +289,7 @@ extern GTY(()) optab optab_table[OTI_MAX];
 #define smod_optab (optab_table[OTI_smod])
 #define umod_optab (optab_table[OTI_umod])
 #define fmod_optab (optab_table[OTI_fmod])
-#define drem_optab (optab_table[OTI_drem])
+#define remainder_optab (optab_table[OTI_remainder])
 #define ftrunc_optab (optab_table[OTI_ftrunc])
 #define and_optab (optab_table[OTI_and])
 #define ior_optab (optab_table[OTI_ior])
index b69034778325712f9c510948e793e35979653f47..264d5992d394375069c67c93e700c0c6ecf0b294 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-25  Uros Bizjak  <uros@kss-loka.si>
+
+       * gcc.dg/builtins-40.c: Also check remainder(), remainderf()
+       and remainderl() built-in functions.  Remove -ffast-math from
+       dg-options.
+
 2006-10-24  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/torture/builtin-math-2.c: Add checks for asin, acos,
index 405c8723309af8c1ebb5c9443e065d0df1ff5afe..982175a3a6b631224a5c500cda5e33367821d50d 100644 (file)
@@ -1,18 +1,24 @@
 /* Copyright (C) 2004 Free Software Foundation.
 
-   Check that fmod, fmodf, fmodl, drem, dremf and dreml
+   Check that fmod, fmodf, fmodl, drem, dremf, dreml,
+   remainder, remainderf and remainderl
    built-in functions compile.
 
    Written by Uros Bizjak, 5th May 2004.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O2 -ffast-math" } */
+/* { dg-options "-O2" } */
 
 extern double fmod(double, double);
-extern double drem(double, double);
 extern float fmodf(float, float);
-extern float dremf(float, float);
 extern long double fmodl(long double, long double);
+
+extern double remainder(double, double);
+extern float remainderf(float, float);
+extern long double remainderl(long double, long double);
+
+extern double drem(double, double);
+extern float dremf(float, float);
 extern long double dreml(long double, long double);
 
 
@@ -21,27 +27,42 @@ double test1(double x, double y)
   return fmod(x, y);
 }
 
-double test2(double x, double y)
+float test1f(float x, float y)
 {
-  return drem(x, y);
+  return fmodf(x, y);
 }
 
-float test1f(float x, float y)
+long double test1l(long double x, long double y)
 {
-  return fmodf(x, y);
+  return fmodl(x, y);
 }
 
-float test2f(float x, float y)
+double test2(double x, double y)
 {
-  return dremf(x, y);
+  return remainder(x, y);
 }
 
-long double test1l(long double x, long double y)
+float test2f(float x, float y)
 {
-  return fmodl(x, y);
+  return remainderf(x, y);
 }
 
 long double test2l(long double x, long double y)
+{
+  return remainderl(x, y);
+}
+
+double test3(double x, double y)
+{
+  return drem(x, y);
+}
+
+float test3f(float x, float y)
+{
+  return dremf(x, y);
+}
+
+long double test3l(long double x, long double y)
 {
   return dreml(x, y);
 }