public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wxzkenny at aliyun dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/31227] The value of cos varies with different optimization levels
Date: Thu, 11 Jan 2024 03:20:25 +0000	[thread overview]
Message-ID: <bug-31227-131-spToK6bfAo@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31227-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31227

--- Comment #2 from Kenny <wxzkenny at aliyun dot com> ---
(In reply to Andreas Schwab from comment #1)
> When compiling with optimisation the compiler expands the call to cos into a
> constant, using its own implementation to compute the result.  The
> difference of one ULP between different implementations is well within the
> expected bounds.  You can use -fno-builtin-cos to force the use of the
> implementation in libm.

I added -fno-builtin-cos according to your instructions and conducted the test
again, and found that the result became stable, but the result of ARM platform
was different from that of X86 platform. Is this expected? 

the glibc version of ARM is 2.28, but the X86 is 2.17

[root@localhost tmp]# uname -a
Linux localhost.localdomain 4.19.90-23.32.v2101.ky10.aarch64 #1 SMP Fri
Feb 24 10:12:55 CST 2023 aarch64 aarch64 aarch64 GNU/Linux
[root@localhost tmp]# gcc -o test_cos -lm -g -fno-builtin-cos test_cos.c
&& ./test_cos
cos(d) = -0.13673722176390940 bfc1809af3cf9a1a
[root@localhost tmp]# gcc -o test_cos -lm -g -O -fno-builtin-cos
test_cos.c && ./test_cos
cos(d) = -0.13673722176390940 bfc1809af3cf9a1a
[root@localhost tmp]# gcc -o test_cos -lm -g -O1 -fno-builtin-cos
test_cos.c && ./test_cos
cos(d) = -0.13673722176390940 bfc1809af3cf9a1a
[root@localhost tmp]# gcc -o test_cos -lm -g -O2 -fno-builtin-cos
test_cos.c && ./test_cos
cos(d) = -0.13673722176390940 bfc1809af3cf9a1a
[root@localhost tmp]# gcc -o test_cos -lm -g -O3 -fno-builtin-cos
test_cos.c && ./test_cos
cos(d) = -0.13673722176390940 bfc1809af3cf9a1a

[root@localhost tmp]#  uname -a
Linux xiaozhong-wang 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17
15:42:21 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost tmp]#  gcc -o test_cos -lm -g -fno-builtin-cos
test_cos.c && ./test_cos
cos(d) = -0.13673722176390943 bfc1809af3cf9a1b
[root@localhost tmp]#  gcc -o test_cos -lm -g -O -fno-builtin-cos
test_cos.c && ./test_cos
cos(d) = -0.13673722176390943 bfc1809af3cf9a1b
[root@localhost tmp]#  gcc -o test_cos -lm -g -O1 -fno-builtin-cos
test_cos.c && ./test_cos
cos(d) = -0.13673722176390943 bfc1809af3cf9a1b
[root@localhost tmp]#  gcc -o test_cos -lm -g -O2 -fno-builtin-cos
test_cos.c && ./test_cos
cos(d) = -0.13673722176390943 bfc1809af3cf9a1b
[root@localhost tmp]#  gcc -o test_cos -lm -g -O3 -fno-builtin-cos
test_cos.c && ./test_cos
cos(d) = -0.13673722176390943 bfc1809af3cf9a1b

-- 
You are receiving this mail because:
You are on the CC list for the bug.

      parent reply	other threads:[~2024-01-11  3:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10  1:20 [Bug libc/31227] New: " wxzkenny at aliyun dot com
2024-01-10  9:38 ` [Bug libc/31227] " schwab@linux-m68k.org
2024-01-11  3:20 ` wxzkenny at aliyun dot com [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31227-131-spToK6bfAo@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).