From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EC7C638582B7; Thu, 11 Jan 2024 03:20:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC7C638582B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1704943225; bh=IXICSHA4q2oL1ia+FeS0FwkLrtyB6KQBYcH/hFlcIeU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VDgyFH4LJeACbyohJRWQ18DfdfQlT9XiHcQYns88P09nSgvQAezaXnDZhynWDF+xC /d6Bg2X4emjKUYcejRRXXPSyRvigm/gxMeLBr3DhIYDL4Wx0DgrA+syBI31JdkWcn2 4Nv9Y/nX16LcmqXGMbQvVvjVOHp6L2f4GS/giaHM= From: "wxzkenny at aliyun dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.28 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: wxzkenny at aliyun dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: NOTABUG X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31227 --- Comment #2 from Kenny --- (In reply to Andreas Schwab from comment #1) > When compiling with optimisation the compiler expands the call to cos int= o 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 t= est again, and found that the result became stable, but the result of ARM platf= orm was different from that of X86 platform. Is this expected?=20 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) =3D -0.13673722176390940 bfc1809af3cf9a1a [root@localhost tmp]# gcc -o test_cos -lm -g -O -fno-builtin-cos test_cos.c && ./test_cos cos(d) =3D -0.13673722176390940 bfc1809af3cf9a1a [root@localhost tmp]# gcc -o test_cos -lm -g -O1 -fno-builtin-cos test_cos.c && ./test_cos cos(d) =3D -0.13673722176390940 bfc1809af3cf9a1a [root@localhost tmp]# gcc -o test_cos -lm -g -O2 -fno-builtin-cos test_cos.c && ./test_cos cos(d) =3D -0.13673722176390940 bfc1809af3cf9a1a [root@localhost tmp]# gcc -o test_cos -lm -g -O3 -fno-builtin-cos test_cos.c && ./test_cos cos(d) =3D -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) =3D -0.13673722176390943 bfc1809af3cf9a1b [root@localhost tmp]# gcc -o test_cos -lm -g -O -fno-builtin-cos test_cos.c && ./test_cos cos(d) =3D -0.13673722176390943 bfc1809af3cf9a1b [root@localhost tmp]# gcc -o test_cos -lm -g -O1 -fno-builtin-cos test_cos.c && ./test_cos cos(d) =3D -0.13673722176390943 bfc1809af3cf9a1b [root@localhost tmp]# gcc -o test_cos -lm -g -O2 -fno-builtin-cos test_cos.c && ./test_cos cos(d) =3D -0.13673722176390943 bfc1809af3cf9a1b [root@localhost tmp]# gcc -o test_cos -lm -g -O3 -fno-builtin-cos test_cos.c && ./test_cos cos(d) =3D -0.13673722176390943 bfc1809af3cf9a1b --=20 You are receiving this mail because: You are on the CC list for the bug.=