From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D950D38618EE; Sat, 31 Oct 2020 08:57:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D950D38618EE From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/97653] New: Incorrect long double calculation with -mabi=ibmlongdouble Date: Sat, 31 Oct 2020 08:57:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone cf_gcctarget Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 08:57:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97653 Bug ID: 97653 Summary: Incorrect long double calculation with -mabi=3Dibmlongdouble Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org CC: bergner at vnet dot ibm.com Target Milestone: --- Target: powerpc64le-unknown-linux-gnu GCC configured with --with-long-double-format=3Dieee produces incorrect res= ults when compiling with -mabi=3Dibmlongdouble This code (reduced from 26_numerics/random/knuth_b.cc in the libstdc++ testsuite) fails the assertion: #include int printf(const char*, ...); unsigned long min() { return 1; } unsigned long max() { return 2147483646; } unsigned long k =3D 256; unsigned long y =3D 1465645203; unsigned long f() { long double r =3D ((y - min()) / (max() - min() + 1.0L)); assert( r < 1 ); unsigned long j =3D k * ((y - min()) / (max() - min() + 1.0L)); assert( j < k ); return j; } int main() { printf("%lu\n", f()); } $ ~/gcc/ieee128/bin/gcc k.c -mno-gnu-attribute -mabi=3Dibmlongdouble && ./a= .out a.out: k.c:16: f: Assertion `j < k' failed. Aborted (core dumped) $ ~/gcc/ieee128/bin/gcc -v Using built-in specs. COLLECT_GCC=3D/home/test/gcc/ieee128/bin/gcc COLLECT_LTO_WRAPPER=3D/home/test/gcc/ieee128/libexec/gcc/powerpc64le-unknow= n-linux-gnu/11.0.0/lto-wrapper Target: powerpc64le-unknown-linux-gnu Configured with: ../gcc/configure --prefix=3D/home/test/gcc/ieee128/ --enable-libstdcxx-debug --disable-bootstrap --disable-multilib --disable-libvtv --with-system-zlib --without-isl --with-long-double-format=3Dieee --enable-languages=3Dc,c++ Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.0.0 20201030 (experimental) (GCC)=20 This is an up to date Fedora 33 system: # rpm -q glibc glibc-2.32-1.fc33.ppc64le # lscpu Architecture: ppc64le Byte Order: Little Endian CPU(s): 160 On-line CPU(s) list: 0-159 Thread(s) per core: 4 Core(s) per socket: 20 Socket(s): 2 NUMA node(s): 2 Model: 2.2 (pvr 004e 1202) Model name: POWER9, altivec supported Frequency boost: enabled CPU max MHz: 3800.0000 CPU min MHz: 2166.0000 L1d cache: 1.3 MiB L1i cache: 1.3 MiB L2 cache: 10 MiB L3 cache: 200 MiB NUMA node0 CPU(s): 0-79 NUMA node8 CPU(s): 80-159 Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Mitigation; RFI Flush, L1D private per thr= ead Vulnerability Mds: Not affected Vulnerability Meltdown: Mitigation; RFI Flush, L1D private per thr= ead Vulnerability Spec store bypass: Mitigation; Kernel entry/exit barrier (eie= io) Vulnerability Spectre v1: Mitigation; __user pointer sanitization, o= ri31 speculation barrier enabled Vulnerability Spectre v2: Mitigation; Indirect branch cache disabled, Software link stack flush Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected=