Bug 220989 - lib/msun/trig_test fails with clang 5.0+
Summary: lib/msun/trig_test fails with clang 5.0+
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: tests (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-25 03:35 UTC by Enji Cooper
Modified: 2017-09-26 09:03 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 commit-hook freebsd_committer freebsd_triage 2017-07-25 03:49:24 UTC
A commit references this bug:

Author: ngie
Date: Tue Jul 25 03:48:25 UTC 2017
New revision: 321454
URL: https://svnweb.freebsd.org/changeset/base/321454

Log:
  Mark :reduction as an expected failure

  It fails with clang 5.0+.

  PR:	220989
  MFC after:	2 months
  MFC with:	r321369
  Reported by:	Jenkins

Changes:
  projects/runtime-coverage/lib/msun/tests/trig_test.c
Comment 2 commit-hook freebsd_committer freebsd_triage 2017-07-25 03:57:32 UTC
A commit references this bug:

Author: ngie
Date: Tue Jul 25 03:56:42 UTC 2017
New revision: 321457
URL: https://svnweb.freebsd.org/changeset/base/321457

Log:
  Mark :reduction as an expected failure

  It fails with clang 5.0+.

  PR:	220989
  MFC after:	2 months
  MFC with:	r321369
  Reported by:	Jenkins

Changes:
  head/lib/msun/tests/trig_test.c
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2017-07-25 21:00:30 UTC
I tried adding a bit of debug info, and with a "good" libm, the first result is:

DBG: ld_pi_odd[0] = 1.18918869603738415962e+101,
     sinl() = 2.47267281071058784804e-22,
     fabsl() = 2.47267281071058784804e-22,
     LDBL_EPSILON = 1.08420217248550443401e-19

With a "bad" libm (compiled by clang 5.0.0), it becomes:

DBG: ld_pi_odd[0] = 1.18918869603738415962e+101,
     sinl() = 6.81892800593498228635e-01,
     fabsl() = 6.81892800593498228635e-01,
     LDBL_EPSILON = 1.08420217248550443401e-19

E.g. the sinl() result is completely off.  I did some bisection, and it seems to have regressed with this upstream commit:

  https://reviews.llvm.org/rL307529
  ("This patch completely replaces the scheduling information for the SandyBridge architecture target by modifying the file X86SchedSandyBridge.td located under the X86 Target")

I am not entirely sure why such a commit would influence the operation of e.g. sinl() on generic amd64, since it does not use any Sandy Bridge specific assembly or the like.  Maybe it exposes some other bug in the X86 code generation for long doubles?  Or maybe there is some sort of undefined behavior in our sinl() implementation that is now being over-optimized?

The challenge here is to come up with a good minimized test case for upstream, so we can submit this as a concrete bug.  Maybe it is easiest to just copy paste all of the sinl() implementation plus the relevant part of trig_test.c into one big .c file, and make it print and/or check the end result.
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2017-07-29 20:03:44 UTC
This is the difference in assembly output for s_sinl.pico, which is the only file that seems to cause the problem:

--- obj-r307528/s_sinl-min.s    2017-07-29 22:00:53.371688000 +0200
+++ obj-r307529/s_sinl-min.s    2017-07-29 22:01:43.929787000 +0200
@@ -179,7 +179,6 @@
        jbe     .LBB0_9
 .LBB0_14:                               # %if.end80.i
        fstp    %st(0)
-       shll    $16, %ebx
        movq    %rax, -96(%rbp)
        movw    $16406, -88(%rbp)       # imm = 0x4016
        fldt    -96(%rbp)
@@ -194,18 +193,19 @@
        movsd   %xmm0, -48(%rbp)
        movsd   %xmm0, -152(%rbp)
        fsubl   -152(%rbp)
-       flds    .LCPI0_1(%rip)
-       fmul    %st(0), %st(1)
        fnstcw  -66(%rbp)
+       flds    .LCPI0_1(%rip)
        movzwl  -66(%rbp), %eax
        movw    $3199, -66(%rbp)        # imm = 0xC7F
        fldcw   -66(%rbp)
+       fmul    %st(0), %st(1)
        movw    %ax, -66(%rbp)
        fxch    %st(1)
        fistl   -76(%rbp)
        fldcw   -66(%rbp)
        xorps   %xmm0, %xmm0
        cvtsi2sdl       -76(%rbp), %xmm0
+       shll    $16, %ebx
        movsd   %xmm0, -40(%rbp)
        movsd   %xmm0, -144(%rbp)
        fsubl   -144(%rbp)
@@ -354,5 +354,5 @@
        .size   pio2_3tlo, 8


-       .ident  "clang version 5.0.0 (trunk 307528)"
+       .ident  "clang version 5.0.0 (trunk 307529)"
        .section        ".note.GNU-stack","",@progbits
Comment 5 Dimitry Andric freebsd_committer freebsd_triage 2017-07-29 21:23:42 UTC
(In reply to Dimitry Andric from comment #4)
> This is the difference in assembly output for s_sinl.pico

In particular, the moving of shll $16, %ebx does not matter for the end result, but the following change does:

> @@ -194,18 +193,19 @@
>         movsd   %xmm0, -48(%rbp)
>         movsd   %xmm0, -152(%rbp)
>         fsubl   -152(%rbp)
> -       flds    .LCPI0_1(%rip)
> -       fmul    %st(0), %st(1)
>         fnstcw  -66(%rbp)
> +       flds    .LCPI0_1(%rip)
>         movzwl  -66(%rbp), %eax
>         movw    $3199, -66(%rbp)        # imm = 0xC7F
>         fldcw   -66(%rbp)
> +       fmul    %st(0), %st(1)
>         movw    %ax, -66(%rbp)
>         fxch    %st(1)
>         fistl   -76(%rbp)
>         fldcw   -66(%rbp)
>         xorps   %xmm0, %xmm0
>         cvtsi2sdl       -76(%rbp), %xmm0

E.g. the fld and fmul are moved around, and that botches things up.  This particular part corresponds to the following loop in lib/msun/ld80/e_rem_pio2l.h:

        for(i=0;i<2;i++) {
                tx[i] = (double)((int32_t)(z));
                z     = (z-tx[i])*two24;
        }
Comment 6 Ryan Libby freebsd_committer freebsd_triage 2017-08-23 18:25:20 UTC
(In reply to Dimitry Andric from comment #5)

The fmul is moved to after the fldcw, which is setting the FPU control
word to 0xc7f, which may change the rounding and precision modes.  (I
guess the FPU control word is being set for the purpose of the cast to
int32_t?)  Is clang missing barriers around fldcw?
Comment 7 Dimitry Andric freebsd_committer freebsd_triage 2017-08-23 20:32:58 UTC
(In reply to Ryan Libby from comment #6)
> (In reply to Dimitry Andric from comment #5)
> 
> The fmul is moved to after the fldcw, which is setting the FPU control
> word to 0xc7f, which may change the rounding and precision modes.  (I
> guess the FPU control word is being set for the purpose of the cast to
> int32_t?)  Is clang missing barriers around fldcw?

At some point, upstream did an update of (part of) the instruction scheduler, and this messed up this particular test case.  For the full details, see:

https://bugs.llvm.org/show_bug.cgi?id=34080

Sorry that I didn't link to that upstream bug report earlier here.  The jury is still out on what to do with it for the 5.0.0 release.
Comment 8 commit-hook freebsd_committer freebsd_triage 2017-08-24 20:20:01 UTC
A commit references this bug:

Author: dim
Date: Thu Aug 24 20:19:29 UTC 2017
New revision: 322855
URL: https://svnweb.freebsd.org/changeset/base/322855

Log:
  Upgrade our copies of clang, llvm, lldb and compiler-rt to r311606 from
  the upstream release_50 branch.

  As of this version, lib/msun's trig test should also work correctly
  again (see bug 220989 for more information).

  PR:		220989
  MFC after:	2 months
  X-MFC-with:	r321369

Changes:
_U  head/contrib/compiler-rt/
  head/contrib/compiler-rt/lib/builtins/arm/aeabi_dcmp.S
  head/contrib/compiler-rt/lib/builtins/arm/aeabi_fcmp.S
  head/contrib/compiler-rt/lib/esan/esan_sideline_linux.cpp
  head/contrib/compiler-rt/lib/profile/InstrProfilingNameVar.c
_U  head/contrib/libc++/
_U  head/contrib/llvm/
  head/contrib/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
  head/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
  head/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  head/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  head/contrib/llvm/lib/IR/AutoUpgrade.cpp
  head/contrib/llvm/lib/Object/COFFModuleDefinition.cpp
  head/contrib/llvm/lib/Target/ARM/ARMISelLowering.cpp
  head/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp
  head/contrib/llvm/lib/Target/X86/X86InstrAVX512.td
  head/contrib/llvm/lib/Target/X86/X86SchedSandyBridge.td
  head/contrib/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
  head/contrib/llvm/lib/ToolDrivers/llvm-dlltool/Options.td
  head/contrib/llvm/lib/Transforms/Scalar/LowerAtomic.cpp
  head/contrib/llvm/lib/Transforms/Scalar/Reassociate.cpp
  head/contrib/llvm/lib/Transforms/Utils/CloneFunction.cpp
_U  head/contrib/llvm/tools/clang/
  head/contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h
  head/contrib/llvm/tools/clang/include/clang/Lex/Preprocessor.h
  head/contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp
  head/contrib/llvm/tools/clang/lib/AST/DeclCXX.cpp
  head/contrib/llvm/tools/clang/lib/CodeGen/CGCXXABI.cpp
  head/contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp
  head/contrib/llvm/tools/clang/lib/CodeGen/MicrosoftCXXABI.cpp
  head/contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.cpp
  head/contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.cpp
  head/contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.h
  head/contrib/llvm/tools/clang/lib/Format/WhitespaceManager.cpp
  head/contrib/llvm/tools/clang/lib/Headers/unwind.h
  head/contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp
  head/contrib/llvm/tools/clang/lib/Lex/Preprocessor.cpp
  head/contrib/llvm/tools/clang/lib/Parse/Parser.cpp
  head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp
  head/contrib/llvm/tools/clang/lib/Sema/SemaObjCProperty.cpp
  head/contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp
  head/contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp
  head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
_U  head/contrib/llvm/tools/lld/
_U  head/contrib/llvm/tools/lldb/
  head/contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
  head/contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h
  head/lib/clang/include/clang/Basic/Version.inc
  head/lib/clang/include/lld/Config/Version.inc
  head/lib/clang/include/llvm/Support/VCSRevision.h
Comment 9 Dimitry Andric freebsd_committer freebsd_triage 2017-08-25 10:20:49 UTC
Ngie, if you could verify that reverting r321457 now makes trig_test work OK, can we close this bug?
Comment 10 commit-hook freebsd_committer freebsd_triage 2017-08-26 06:45:00 UTC
A commit references this bug:

Author: ngie
Date: Sat Aug 26 06:44:50 UTC 2017
New revision: 322921
URL: https://svnweb.freebsd.org/changeset/base/322921

Log:
  Revert r321457

  It doesn't fail after ^/head@r322855 (the releng_50 clang merge).

  PR:	220989
  MFC after:	2 months
  MFC with:	r321369, r322855

Changes:
  head/lib/msun/tests/trig_test.c
Comment 11 Enji Cooper freebsd_committer freebsd_triage 2017-08-26 06:45:39 UTC
(In reply to commit-hook from comment #10)

I confirmed this was the case per ci.freebsd.org: https://ci.freebsd.org/job/FreeBSD-head-amd64-test/4046/testReport/junit/lib.msun/trig_test/reduction/ .
Comment 12 commit-hook freebsd_committer freebsd_triage 2017-09-26 09:03:35 UTC
A commit references this bug:

Author: dim
Date: Tue Sep 26 09:02:00 UTC 2017
New revision: 324006
URL: https://svnweb.freebsd.org/changeset/base/324006

Log:
  Synchronize most of libm with head as of r323004.  This excludes a few
  arch-specific updates for powerpcspe, mips and riscv, for which support
  has not been merged yet.

  Bump __FreeBSD_version for the addition of cacoshl, cacosl, casinhl,
  casinl, catanl, catanhl, sincos, sincosf, and sincosl.

  MFC r305382 (by bde):

    Add asm versions of fmod(), fmodf() and fmodl() on amd64.  Add asm
    versions of fmodf() amd fmodl() on i387.

    fmod is similar to remainder, and the C versions are 3 to 9 times
    slower than the asm versions on x86 for both, but we had the strange
    mixture of all 6 variants of remainder in asm and only 1 of 6
    variants of fmod in asm.

  MFC r305384 (by bde):

    Disconnect the "optimized" asm variants of cos(), sin() and tan() from
    the build on i386.  Leave them in the source tree for regression tests.

    The asm functions were always much less accurate (by a factor of more
    than 10**18 in the worst case).  They were faster on old CPUs.  But
    with each new generation of CPUs they get relatively slower.  The
    double precision C version's average advantage is about a factor of 2
    on Haswell.

    The asm functions were already intentionally avoided in float and long
    double precision on i386 and in all precisions on amd64.  Float
    precision and amd64 give larger advantages to the C version.  The long
    double precision C code and compilers' understanding of long double
    precision are not so good, so the i387 is still slightly faster for
    long double precision, except for the unimportant subcase of huge args
    where the sub-optimal C code now somehow beats the i387 by about a
    factor of 2.

  MFC r305385 (by bde):

    Oops, the previous i386 version of e_fmodf.S and e_fmodl.S was
    actually the amd64 version.

  MFC r306409 (by emaste):

    libm: fix some unused variable (rcsid) and dangling else warnings

    s_{fabs,fmax,logb,scalb}{,f,l}.c may be built elsewhere with a higher
    WARNS setting.

    Reviewed by:	ed
    Sponsored by:	The FreeBSD Foundation
    Differential Revision:	https://reviews.freebsd.org/D8061

  MFC r306410 (by emaste):

    libm: simplify i387 subdir logic with make's :S substitution

  MFC r306527 (by emaste):

    libm: remove unused variables for LDBL_MANT_DIG != 113

    Sponsored by:	The FreeBSD Foundation

  MFC r306709 (by emaste):

    libm: remove unused variables

    Sponsored by:	The FreeBSD Foundation

  MFC r307066 (by br):

    Don't use fmaxl/fminl on platforms with no long double support,
    use fmax/fmin instead.

    This fixes fmaxmin test failure on MIPS64.

    Reviewed by:	emaste
    Sponsored by:	DARPA, AFRL
    Sponsored by:	HEIF5
    Differential Revision:	https://reviews.freebsd.org/D8216

  MFC r308172 (by emaste):

    libm: add braces around initialization of subobjects

    This cleans up a warning when building libm at higher WARNS levels and
    makes the intent more clear. By the C standard the values are assigned
    to subobject members in order so this change introduces no functional
    change. (6.7.9 20)

    Reviewed by:	kib
    Sponsored by:	The FreeBSD Foundation
    Differential Revision:	https://reviews.freebsd.org/D8333

  MFC r313761 (by mmokhi):

    Add casinl() cacosl() catanl() casinhl() cacoshl() catanhl() APIs to msun
    to improve C11 conformance.

    PR:		216850 216851 216852 216856 216857 216858
    Submitted by:	mmokhi
    Reported by:	sgk@troutmask.apl.washington.edu
    Reviewed by:	bde, mat, theraven
    Approved by:	bde (src committer), mat (mentor)
    Differential Revision:	https://reviews.freebsd.org/D9491

  MFC r313863 (by mmokhi):

    Fix building of r313761 on platforms that
    `long double` is alias of `double` (MIPS, etc)

    PR:		216850 216851 216852 216856 216857 216858
    Reported by:	emsate
    Reviewed by:	bde emaste hselasky
    Approved by:	bde emaste hselasky
    Differential Revision:	https://reviews.freebsd.org/D9491

  MFC r313864 (by mmokhi):

    Add documentations related to new APIs of r313761

    PR:		216850 216851 216852 216856 216857 216858
    Submitted by:	sgk@troutmask.apl.washington.edu
    Reported by:	sgk@troutmask.apl.washington.edu
    Reviewed by:	bde emaste hselasky
    Approved by:	bde emaste hselasky
    Differential Revision:	https://reviews.freebsd.org/D9491

  MFC r314950 (by ngie):

    Don't expect :test_large_inputs to fail with i386 anymore

    Recent changes (maybe a side-effect of the ATF-ification in r314649)
    invalidate the failure expectation.

    PR:		205446
    Sponsored by:	Dell EMC Isilon

  MFC r317349 (by pfg):

    msun: Remove trailing space in Sunsoft copyright statement.

    Submittedby:	kargl

  MFC r319047 (by mmel):

    Implement sincos, sincosf, and sincosl.
    The primary benefit of these functions is that argument
    reduction is done once instead of twice in independent
    calls to sin() and cos().

    * lib/msun/Makefile:
      . Add s_sincos[fl].c to the build.
      . Add sincos.3 documentation.
      . Add appropriate MLINKS.

    * lib/msun/Symbol.map:
      . Expose sincos[fl] symbols in dynamic libm.so.

    * lib/msun/man/sincos.3:
      . Documentation for sincos[fl].

    * lib/msun/src/k_sincos.h:
      . Kernel for sincos() function.  This merges the individual kernels
        for sin() and cos().  The merger offered an opportunity to re-arrange
        the individual kernels for better performance.

    * lib/msun/src/k_sincosf.h:
       . Kernel for sincosf() function.  This merges the individual kernels
         for sinf() and cosf(). The merger offered an opportunity to re-arrange
         the individual kernels for better performance.

    * lib/msun/src/k_sincosl.h:
       . Kernel for sincosl() function.  This merges the individual kernels
         for sinl() and cosl(). The merger offered an opportunity to re-arrange
         the individual kernels for better performance.

    * lib/msun/src/math.h:
      . Add prototytpes for sincos[fl]().

    * lib/msun/src/math_private.h:
      . Add RETURNV macros.  This is needed to reset fpsetprec on I386
        hardware for a function with type void.

    * lib/msun/src/s_sincos.c:
      . Implementation of sincos() where sin() and cos() were merged into
        one routine and possibly re-arranged for better performance.

    * lib/msun/src/s_sincosf.c:
      . Implementation of sincosf() where sinf() and cosf() were merged into
        one routine and possibly re-arranged for better performance.

    * lib/msun/src/s_sincosl.c:
      . Implementation of sincosl() where sinl() and cosl() were merged into
        one routine and possibly re-arranged for better performance.

    PR:		215977, 218300
    Submitted by:	Steven G. Kargl <sgk@troutmask.apl.washington.edu>
    Differential Revision:	https://reviews.freebsd.org/D10765

  MFC r321457 (by ngie):

    Mark :reduction as an expected failure

    It fails with clang 5.0+.

    PR:	220989
    Reported by:	Jenkins

  MFC r322418 (by rlibby):

    lib/msun: avoid referring to broken LDBL_MAX

    LDBL_MAX is broken on i386:
    https://lists.freebsd.org/pipermail/freebsd-numerics/2012-September/000288.html

    Gcc has produced +Infinity for LDBL_MAX on i386 and amd64 with -m32
    for some time, and newer versions of gcc are now warning that the
    "floating constant exceeds range of 'long double'".  Avoid this by
    referring to half the value of LDBL_MAX instead.

    Reviewed by:	bde
    Approved by:	markj (mentor)
    Sponsored by:	Dell EMC Isilon

  MFC r322435 (by rlibby):

    Revert r322418, LDBL_MAX_EXP unsuitable for macro pasting on some arches

    Either need a different way to spell HALF_LDBL_MAX, or a different way
    to spell LDBL_MAX_EXP, or a different approach.

    Reported by:	ian

  MFC r322921 (by ngie):

    Revert r321457

    It doesn't fail after ^/head@r322855 (the releng_50 clang merge).

    PR:	220989

Changes:
_U  stable/11/
  stable/11/lib/msun/Makefile
  stable/11/lib/msun/Symbol.map
  stable/11/lib/msun/amd64/Makefile.inc
  stable/11/lib/msun/amd64/e_fmod.S
  stable/11/lib/msun/amd64/e_fmodf.S
  stable/11/lib/msun/amd64/e_fmodl.S
  stable/11/lib/msun/i387/Makefile.inc
  stable/11/lib/msun/i387/e_fmodf.S
  stable/11/lib/msun/i387/e_fmodl.S
  stable/11/lib/msun/ld80/e_lgammal_r.c
  stable/11/lib/msun/ld80/k_expl.h
  stable/11/lib/msun/ld80/s_logl.c
  stable/11/lib/msun/man/cacos.3
  stable/11/lib/msun/man/sincos.3
  stable/11/lib/msun/src/catrig.c
  stable/11/lib/msun/src/catrigl.c
  stable/11/lib/msun/src/e_asin.c
  stable/11/lib/msun/src/e_coshl.c
  stable/11/lib/msun/src/e_lgammaf_r.c
  stable/11/lib/msun/src/e_sinhl.c
  stable/11/lib/msun/src/k_sincos.h
  stable/11/lib/msun/src/k_sincosf.h
  stable/11/lib/msun/src/k_sincosl.h
  stable/11/lib/msun/src/math.h
  stable/11/lib/msun/src/math_private.h
  stable/11/lib/msun/src/s_fabs.c
  stable/11/lib/msun/src/s_fmax.c
  stable/11/lib/msun/src/s_fmin.c
  stable/11/lib/msun/src/s_logbl.c
  stable/11/lib/msun/src/s_scalbn.c
  stable/11/lib/msun/src/s_scalbnf.c
  stable/11/lib/msun/src/s_scalbnl.c
  stable/11/lib/msun/src/s_sincos.c
  stable/11/lib/msun/src/s_sincosf.c
  stable/11/lib/msun/src/s_sincosl.c
  stable/11/lib/msun/src/s_tanhl.c
  stable/11/lib/msun/tests/ctrig_test.c
  stable/11/sys/sys/param.h
Comment 13 commit-hook freebsd_committer freebsd_triage 2017-09-26 09:03:42 UTC
A commit references this bug:

Author: dim
Date: Tue Sep 26 09:02:00 UTC 2017
New revision: 324006
URL: https://svnweb.freebsd.org/changeset/base/324006

Log:
  Synchronize most of libm with head as of r323004.  This excludes a few
  arch-specific updates for powerpcspe, mips and riscv, for which support
  has not been merged yet.

  Bump __FreeBSD_version for the addition of cacoshl, cacosl, casinhl,
  casinl, catanl, catanhl, sincos, sincosf, and sincosl.

  MFC r305382 (by bde):

    Add asm versions of fmod(), fmodf() and fmodl() on amd64.  Add asm
    versions of fmodf() amd fmodl() on i387.

    fmod is similar to remainder, and the C versions are 3 to 9 times
    slower than the asm versions on x86 for both, but we had the strange
    mixture of all 6 variants of remainder in asm and only 1 of 6
    variants of fmod in asm.

  MFC r305384 (by bde):

    Disconnect the "optimized" asm variants of cos(), sin() and tan() from
    the build on i386.  Leave them in the source tree for regression tests.

    The asm functions were always much less accurate (by a factor of more
    than 10**18 in the worst case).  They were faster on old CPUs.  But
    with each new generation of CPUs they get relatively slower.  The
    double precision C version's average advantage is about a factor of 2
    on Haswell.

    The asm functions were already intentionally avoided in float and long
    double precision on i386 and in all precisions on amd64.  Float
    precision and amd64 give larger advantages to the C version.  The long
    double precision C code and compilers' understanding of long double
    precision are not so good, so the i387 is still slightly faster for
    long double precision, except for the unimportant subcase of huge args
    where the sub-optimal C code now somehow beats the i387 by about a
    factor of 2.

  MFC r305385 (by bde):

    Oops, the previous i386 version of e_fmodf.S and e_fmodl.S was
    actually the amd64 version.

  MFC r306409 (by emaste):

    libm: fix some unused variable (rcsid) and dangling else warnings

    s_{fabs,fmax,logb,scalb}{,f,l}.c may be built elsewhere with a higher
    WARNS setting.

    Reviewed by:	ed
    Sponsored by:	The FreeBSD Foundation
    Differential Revision:	https://reviews.freebsd.org/D8061

  MFC r306410 (by emaste):

    libm: simplify i387 subdir logic with make's :S substitution

  MFC r306527 (by emaste):

    libm: remove unused variables for LDBL_MANT_DIG != 113

    Sponsored by:	The FreeBSD Foundation

  MFC r306709 (by emaste):

    libm: remove unused variables

    Sponsored by:	The FreeBSD Foundation

  MFC r307066 (by br):

    Don't use fmaxl/fminl on platforms with no long double support,
    use fmax/fmin instead.

    This fixes fmaxmin test failure on MIPS64.

    Reviewed by:	emaste
    Sponsored by:	DARPA, AFRL
    Sponsored by:	HEIF5
    Differential Revision:	https://reviews.freebsd.org/D8216

  MFC r308172 (by emaste):

    libm: add braces around initialization of subobjects

    This cleans up a warning when building libm at higher WARNS levels and
    makes the intent more clear. By the C standard the values are assigned
    to subobject members in order so this change introduces no functional
    change. (6.7.9 20)

    Reviewed by:	kib
    Sponsored by:	The FreeBSD Foundation
    Differential Revision:	https://reviews.freebsd.org/D8333

  MFC r313761 (by mmokhi):

    Add casinl() cacosl() catanl() casinhl() cacoshl() catanhl() APIs to msun
    to improve C11 conformance.

    PR:		216850 216851 216852 216856 216857 216858
    Submitted by:	mmokhi
    Reported by:	sgk@troutmask.apl.washington.edu
    Reviewed by:	bde, mat, theraven
    Approved by:	bde (src committer), mat (mentor)
    Differential Revision:	https://reviews.freebsd.org/D9491

  MFC r313863 (by mmokhi):

    Fix building of r313761 on platforms that
    `long double` is alias of `double` (MIPS, etc)

    PR:		216850 216851 216852 216856 216857 216858
    Reported by:	emsate
    Reviewed by:	bde emaste hselasky
    Approved by:	bde emaste hselasky
    Differential Revision:	https://reviews.freebsd.org/D9491

  MFC r313864 (by mmokhi):

    Add documentations related to new APIs of r313761

    PR:		216850 216851 216852 216856 216857 216858
    Submitted by:	sgk@troutmask.apl.washington.edu
    Reported by:	sgk@troutmask.apl.washington.edu
    Reviewed by:	bde emaste hselasky
    Approved by:	bde emaste hselasky
    Differential Revision:	https://reviews.freebsd.org/D9491

  MFC r314950 (by ngie):

    Don't expect :test_large_inputs to fail with i386 anymore

    Recent changes (maybe a side-effect of the ATF-ification in r314649)
    invalidate the failure expectation.

    PR:		205446
    Sponsored by:	Dell EMC Isilon

  MFC r317349 (by pfg):

    msun: Remove trailing space in Sunsoft copyright statement.

    Submittedby:	kargl

  MFC r319047 (by mmel):

    Implement sincos, sincosf, and sincosl.
    The primary benefit of these functions is that argument
    reduction is done once instead of twice in independent
    calls to sin() and cos().

    * lib/msun/Makefile:
      . Add s_sincos[fl].c to the build.
      . Add sincos.3 documentation.
      . Add appropriate MLINKS.

    * lib/msun/Symbol.map:
      . Expose sincos[fl] symbols in dynamic libm.so.

    * lib/msun/man/sincos.3:
      . Documentation for sincos[fl].

    * lib/msun/src/k_sincos.h:
      . Kernel for sincos() function.  This merges the individual kernels
        for sin() and cos().  The merger offered an opportunity to re-arrange
        the individual kernels for better performance.

    * lib/msun/src/k_sincosf.h:
       . Kernel for sincosf() function.  This merges the individual kernels
         for sinf() and cosf(). The merger offered an opportunity to re-arrange
         the individual kernels for better performance.

    * lib/msun/src/k_sincosl.h:
       . Kernel for sincosl() function.  This merges the individual kernels
         for sinl() and cosl(). The merger offered an opportunity to re-arrange
         the individual kernels for better performance.

    * lib/msun/src/math.h:
      . Add prototytpes for sincos[fl]().

    * lib/msun/src/math_private.h:
      . Add RETURNV macros.  This is needed to reset fpsetprec on I386
        hardware for a function with type void.

    * lib/msun/src/s_sincos.c:
      . Implementation of sincos() where sin() and cos() were merged into
        one routine and possibly re-arranged for better performance.

    * lib/msun/src/s_sincosf.c:
      . Implementation of sincosf() where sinf() and cosf() were merged into
        one routine and possibly re-arranged for better performance.

    * lib/msun/src/s_sincosl.c:
      . Implementation of sincosl() where sinl() and cosl() were merged into
        one routine and possibly re-arranged for better performance.

    PR:		215977, 218300
    Submitted by:	Steven G. Kargl <sgk@troutmask.apl.washington.edu>
    Differential Revision:	https://reviews.freebsd.org/D10765

  MFC r321457 (by ngie):

    Mark :reduction as an expected failure

    It fails with clang 5.0+.

    PR:	220989
    Reported by:	Jenkins

  MFC r322418 (by rlibby):

    lib/msun: avoid referring to broken LDBL_MAX

    LDBL_MAX is broken on i386:
    https://lists.freebsd.org/pipermail/freebsd-numerics/2012-September/000288.html

    Gcc has produced +Infinity for LDBL_MAX on i386 and amd64 with -m32
    for some time, and newer versions of gcc are now warning that the
    "floating constant exceeds range of 'long double'".  Avoid this by
    referring to half the value of LDBL_MAX instead.

    Reviewed by:	bde
    Approved by:	markj (mentor)
    Sponsored by:	Dell EMC Isilon

  MFC r322435 (by rlibby):

    Revert r322418, LDBL_MAX_EXP unsuitable for macro pasting on some arches

    Either need a different way to spell HALF_LDBL_MAX, or a different way
    to spell LDBL_MAX_EXP, or a different approach.

    Reported by:	ian

  MFC r322921 (by ngie):

    Revert r321457

    It doesn't fail after ^/head@r322855 (the releng_50 clang merge).

    PR:	220989

Changes:
_U  stable/11/
  stable/11/lib/msun/Makefile
  stable/11/lib/msun/Symbol.map
  stable/11/lib/msun/amd64/Makefile.inc
  stable/11/lib/msun/amd64/e_fmod.S
  stable/11/lib/msun/amd64/e_fmodf.S
  stable/11/lib/msun/amd64/e_fmodl.S
  stable/11/lib/msun/i387/Makefile.inc
  stable/11/lib/msun/i387/e_fmodf.S
  stable/11/lib/msun/i387/e_fmodl.S
  stable/11/lib/msun/ld80/e_lgammal_r.c
  stable/11/lib/msun/ld80/k_expl.h
  stable/11/lib/msun/ld80/s_logl.c
  stable/11/lib/msun/man/cacos.3
  stable/11/lib/msun/man/sincos.3
  stable/11/lib/msun/src/catrig.c
  stable/11/lib/msun/src/catrigl.c
  stable/11/lib/msun/src/e_asin.c
  stable/11/lib/msun/src/e_coshl.c
  stable/11/lib/msun/src/e_lgammaf_r.c
  stable/11/lib/msun/src/e_sinhl.c
  stable/11/lib/msun/src/k_sincos.h
  stable/11/lib/msun/src/k_sincosf.h
  stable/11/lib/msun/src/k_sincosl.h
  stable/11/lib/msun/src/math.h
  stable/11/lib/msun/src/math_private.h
  stable/11/lib/msun/src/s_fabs.c
  stable/11/lib/msun/src/s_fmax.c
  stable/11/lib/msun/src/s_fmin.c
  stable/11/lib/msun/src/s_logbl.c
  stable/11/lib/msun/src/s_scalbn.c
  stable/11/lib/msun/src/s_scalbnf.c
  stable/11/lib/msun/src/s_scalbnl.c
  stable/11/lib/msun/src/s_sincos.c
  stable/11/lib/msun/src/s_sincosf.c
  stable/11/lib/msun/src/s_sincosl.c
  stable/11/lib/msun/src/s_tanhl.c
  stable/11/lib/msun/tests/ctrig_test.c
  stable/11/sys/sys/param.h