Bug 23584 - math/test-ildouble-fma, math/test-ldouble-fma test suite failures on ppc64le
Summary: math/test-ildouble-fma, math/test-ldouble-fma test suite failures on ppc64le
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.28
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-29 16:18 UTC by Florian Weimer
Modified: 2019-01-16 12:43 UTC (History)
1 user (show)

See Also:
Host:
Target: ppc64le
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2018-08-29 16:18:43 UTC
We see this failure:

=====FAIL: math/test-ildouble-fma.out=====
testing long double (inline functions)
Failure: Test: fma_downward (inf, inf, -max_value)
Result:
 is:         qNaN
 should be:   inf   inf
Failure: Test: fma_downward (-inf, -inf, -max_value)
Result:
 is:         qNaN
 should be:   inf   inf
Failure: Test: fma_upward (inf, -inf, max_value)
Result:
 is:         qNaN
 should be:  -inf  -inf
Failure: Test: fma_upward (-inf, inf, max_value)
Result:
 is:         qNaN
 should be:  -inf  -inf
Test suite completed:
  1458 test cases plus 0 tests for exception flags and
    0 tests for errno executed.
  4 errors occurred.

=====FAIL: math/test-ldouble-fma.out=====
testing long double (without inline functions)
Failure: fma_downward (inf, inf, -max_value): Exception "Invalid operation" set
Failure: fma_downward (inf, inf, -max_value): Exception "Overflow" set
Failure: Test: fma_downward (inf, inf, -max_value)
Result:
 is:         qNaN
 should be:   inf   inf
Failure: fma_downward (inf, -inf, -max_value): Exception "Overflow" set
Failure: fma_downward (-inf, inf, -max_value): Exception "Overflow" set
Failure: fma_downward (-inf, -inf, -max_value): Exception "Invalid operation" set
Failure: fma_downward (-inf, -inf, -max_value): Exception "Overflow" set
Failure: Test: fma_downward (-inf, -inf, -max_value)
Result:
 is:         qNaN
 should be:   inf   inf
Failure: fma_upward (inf, inf, max_value): Exception "Overflow" set
Failure: fma_upward (inf, -inf, max_value): Exception "Invalid operation" set
Failure: fma_upward (inf, -inf, max_value): Exception "Overflow" set
Failure: Test: fma_upward (inf, -inf, max_value)
Result:
 is:         qNaN
 should be:  -inf  -inf
Failure: fma_upward (-inf, inf, max_value): Exception "Invalid operation" set
Failure: fma_upward (-inf, inf, max_value): Exception "Overflow" set
Failure: Test: fma_upward (-inf, inf, max_value)
Result:
 is:         qNaN
 should be:  -inf  -inf
Failure: fma_upward (-inf, -inf, max_value): Exception "Overflow" set
Test suite completed:
  1458 test cases plus 1454 tests for exception flags and
    1454 tests for errno executed.
  16 errors occurred.

glibc was compiled with:

gcc version 8.2.1 20180726 (Red Hat 8.2.1-1) (GCC) 

After fesetround (3), I see this call:

Breakpoint 1, 0x00007ffff7e73718 in __fmal (x=inf, y=inf, z=-1.79769313486231580793728971405301e+308)
    at ../sysdeps/ieee754/ldbl-128ibm/s_fmal.c:128

the true branch of this if statement:

155	  /* If x or y or z is Inf/NaN, or if x * y is zero, compute as x * y
156	     + z.  */
157	  if (xexp == 0x7ff || yexp == 0x7ff || zexp == 0x7ff
158	      || x == 0 || y == 0)
159	    return (x * y) + z;

Which is implemented as:

=> 0x00007ffff7e739f0 <+736>:	fmr     f3,f28
   0x00007ffff7e739f4 <+740>:	fmr     f4,f29
   0x00007ffff7e739f8 <+744>:	fmr     f1,f12
   0x00007ffff7e739fc <+748>:	fmr     f2,f13
   0x00007ffff7e73a00 <+752>:	bl      0x7ffff7ee4db8 <__gcc_qmul+8>
   0x00007ffff7e73a04 <+756>:	nop
   0x00007ffff7e73a08 <+760>:	fmr     f3,f30
   0x00007ffff7e73a0c <+764>:	fmr     f4,f31
   0x00007ffff7e73a10 <+768>:	bl      0x7ffff7ee4c98 <__gcc_qadd+8>
   0x00007ffff7e73a14 <+772>:	nop
   0x00007ffff7e73a18 <+776>:	fmr     f31,f2
   0x00007ffff7e73a1c <+780>:	fmr     f30,f1
   0x00007ffff7e73a20 <+784>:	ld      r9,216(r1)
   0x00007ffff7e73a24 <+788>:	ld      r10,-28688(r13)
   0x00007ffff7e73a28 <+792>:	xor.    r9,r9,r10
   0x00007ffff7e73a2c <+796>:	li      r10,0
   0x00007ffff7e73a30 <+800>:	fmr     f1,f30
   0x00007ffff7e73a34 <+804>:	fmr     f2,f31

Our __gcc_qmul looks like this (I think):

(gdb) disassemble 0x7ffff7ee4db8
Dump of assembler code for function __gcc_qmul:
   0x00007ffff7ee4db0 <+0>:	addis   r2,r12,9
   0x00007ffff7ee4db4 <+4>:	addi    r2,r2,10320
   0x00007ffff7ee4db8 <+8>:	fmul    f0,f1,f3
   0x00007ffff7ee4dbc <+12>:	xxlxor  vs12,vs12,vs12
   0x00007ffff7ee4dc0 <+16>:	fcmpu   cr7,f0,f12
   0x00007ffff7ee4dc4 <+20>:	beq     cr7,0x7ffff7ee4e10 <__gcc_qmul+96>
   0x00007ffff7ee4dc8 <+24>:	ld      r9,-32520(r2)
   0x00007ffff7ee4dcc <+28>:	fabs    f12,f0
   0x00007ffff7ee4dd0 <+32>:	lfd     f10,0(r9)
   0x00007ffff7ee4dd4 <+36>:	fcmpu   cr7,f12,f10
   0x00007ffff7ee4dd8 <+40>:	bge     cr7,0x7ffff7ee4e10 <__gcc_qmul+96>
   0x00007ffff7ee4ddc <+44>:	fmul    f2,f3,f2
   0x00007ffff7ee4de0 <+48>:	fmsub   f3,f1,f3,f0
   0x00007ffff7ee4de4 <+52>:	fmadd   f1,f1,f4,f2
   0x00007ffff7ee4de8 <+56>:	fadd    f1,f1,f3
   0x00007ffff7ee4dec <+60>:	fadd    f11,f0,f1
   0x00007ffff7ee4df0 <+64>:	fabs    f12,f11
   0x00007ffff7ee4df4 <+68>:	fcmpu   cr7,f12,f10
   0x00007ffff7ee4df8 <+72>:	bge     cr7,0x7ffff7ee4e20 <__gcc_qmul+112>
   0x00007ffff7ee4dfc <+76>:	fsub    f0,f0,f11
   0x00007ffff7ee4e00 <+80>:	fadd    f0,f0,f1
   0x00007ffff7ee4e04 <+84>:	fmr     f1,f11
   0x00007ffff7ee4e08 <+88>:	fmr     f2,f0
   0x00007ffff7ee4e0c <+92>:	blr
   0x00007ffff7ee4e10 <+96>:	fmr     f1,f0
   0x00007ffff7ee4e14 <+100>:	xxlxor  vs2,vs2,vs2
   0x00007ffff7ee4e18 <+104>:	blr
   0x00007ffff7ee4e1c <+108>:	ori     r2,r2,0
   0x00007ffff7ee4e20 <+112>:	fmr     f1,f11
   0x00007ffff7ee4e24 <+116>:	xxlxor  vs2,vs2,vs2
   0x00007ffff7ee4e28 <+120>:	blr
   0x00007ffff7ee4e2c <+124>:	.long 0x0
   0x00007ffff7ee4e30 <+128>:	.long 0x0
   0x00007ffff7ee4e34 <+132>:	.long 0x0
End of assembler dump.

__gcc_qadd is this:

(gdb) disassemble 0x7ffff7ee4c98
Dump of assembler code for function __gcc_qadd:
   0x00007ffff7ee4c90 <+0>:	addis   r2,r12,9
   0x00007ffff7ee4c94 <+4>:	addi    r2,r2,10608
   0x00007ffff7ee4c98 <+8>:	fadd    f12,f1,f3
   0x00007ffff7ee4c9c <+12>:	ld      r9,-32520(r2)
   0x00007ffff7ee4ca0 <+16>:	lfd     f10,0(r9)
   0x00007ffff7ee4ca4 <+20>:	fabs    f11,f12
   0x00007ffff7ee4ca8 <+24>:	fcmpu   cr7,f11,f10
   0x00007ffff7ee4cac <+28>:	bge     cr7,0x7ffff7ee4d10 <__gcc_qadd+128>
   0x00007ffff7ee4cb0 <+32>:	fsub    f0,f1,f12
   0x00007ffff7ee4cb4 <+36>:	xxlxor  vs11,vs11,vs11
   0x00007ffff7ee4cb8 <+40>:	fadd    f9,f12,f0
   0x00007ffff7ee4cbc <+44>:	fadd    f3,f3,f0
   0x00007ffff7ee4cc0 <+48>:	fsub    f1,f1,f9
   0x00007ffff7ee4cc4 <+52>:	fadd    f1,f1,f3
   0x00007ffff7ee4cc8 <+56>:	fadd    f1,f1,f2
   0x00007ffff7ee4ccc <+60>:	fadd    f4,f1,f4
   0x00007ffff7ee4cd0 <+64>:	fcmpu   cr7,f4,f11
   0x00007ffff7ee4cd4 <+68>:	beq     cr7,0x7ffff7ee4d00 <__gcc_qadd+112>
   0x00007ffff7ee4cd8 <+72>:	fadd    f11,f12,f4
   0x00007ffff7ee4cdc <+76>:	fabs    f0,f11
   0x00007ffff7ee4ce0 <+80>:	fcmpu   cr7,f0,f10
   0x00007ffff7ee4ce4 <+84>:	bge     cr7,0x7ffff7ee4d60 <__gcc_qadd+208>
   0x00007ffff7ee4ce8 <+88>:	fsub    f1,f12,f11
   0x00007ffff7ee4cec <+92>:	fadd    f4,f1,f4
   0x00007ffff7ee4cf0 <+96>:	fmr     f1,f11
   0x00007ffff7ee4cf4 <+100>:	fmr     f2,f4
   0x00007ffff7ee4cf8 <+104>:	blr
   0x00007ffff7ee4cfc <+108>:	ori     r2,r2,0
   0x00007ffff7ee4d00 <+112>:	fmr     f1,f12
   0x00007ffff7ee4d04 <+116>:	xxlxor  vs2,vs2,vs2
   0x00007ffff7ee4d08 <+120>:	blr
   0x00007ffff7ee4d0c <+124>:	ori     r2,r2,0
   0x00007ffff7ee4d10 <+128>:	ld      r9,-32512(r2)
   0x00007ffff7ee4d14 <+132>:	lfd     f0,0(r9)
   0x00007ffff7ee4d18 <+136>:	fcmpu   cr7,f11,f0
   0x00007ffff7ee4d1c <+140>:	ble     cr7,0x7ffff7ee4d00 <__gcc_qadd+112>
   0x00007ffff7ee4d20 <+144>:	fadd    f4,f4,f2
   0x00007ffff7ee4d24 <+148>:	fadd    f11,f4,f3
   0x00007ffff7ee4d28 <+152>:	fadd    f11,f11,f1
   0x00007ffff7ee4d2c <+156>:	fabs    f0,f11
   0x00007ffff7ee4d30 <+160>:	fcmpu   cr7,f0,f10
   0x00007ffff7ee4d34 <+164>:	bge     cr7,0x7ffff7ee4d60 <__gcc_qadd+208>
   0x00007ffff7ee4d38 <+168>:	fabs    f0,f1
   0x00007ffff7ee4d3c <+172>:	fabs    f12,f3
   0x00007ffff7ee4d40 <+176>:	fcmpu   cr7,f0,f12
   0x00007ffff7ee4d44 <+180>:	ble     cr7,0x7ffff7ee4d70 <__gcc_qadd+224>
   0x00007ffff7ee4d48 <+184>:	fsub    f0,f1,f11
   0x00007ffff7ee4d4c <+188>:	fadd    f1,f0,f3
   0x00007ffff7ee4d50 <+192>:	fadd    f4,f1,f4
   0x00007ffff7ee4d54 <+196>:	b       0x7ffff7ee4cf0 <__gcc_qadd+96>
   0x00007ffff7ee4d58 <+200>:	nop
   0x00007ffff7ee4d5c <+204>:	ori     r2,r2,0
   0x00007ffff7ee4d60 <+208>:	fmr     f1,f11
   0x00007ffff7ee4d64 <+212>:	xxlxor  vs2,vs2,vs2
   0x00007ffff7ee4d68 <+216>:	blr
   0x00007ffff7ee4d6c <+220>:	ori     r2,r2,0
   0x00007ffff7ee4d70 <+224>:	fsub    f3,f3,f11
   0x00007ffff7ee4d74 <+228>:	fadd    f3,f3,f1
   0x00007ffff7ee4d78 <+232>:	fadd    f4,f3,f4
   0x00007ffff7ee4d7c <+236>:	b       0x7ffff7ee4cf0 <__gcc_qadd+96>
   0x00007ffff7ee4d80 <+240>:	.long 0x0
   0x00007ffff7ee4d84 <+244>:	.long 0x0
   0x00007ffff7ee4d88 <+248>:	.long 0x0
End of assembler dump.


I'm not sure if this is a bug in the fmal code or the __gcc_qmul/__gcc_qadd functions.
Comment 1 Andreas Schwab 2018-08-29 16:38:02 UTC
IBM long double only supports default rounding.  Looks like there are some XFAIL_ROUNDING_IBM128_LIBGCC missing.
Comment 2 jsm-csl@polyomino.org.uk 2018-08-29 16:40:21 UTC
I didn't see any response to my review questions at 
https://sourceware.org/ml/libc-alpha/2018-06/msg00375.html following 
Tulio's patch.
Comment 3 Sourceware Commits 2018-10-02 17:18:19 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  f346b5b38ce83ebc832590273e134c53adc06f21 (commit)
      from  4a06ceea33ecc220bbfe264d8f1e74de2f04e90d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f346b5b38ce83ebc832590273e134c53adc06f21

commit f346b5b38ce83ebc832590273e134c53adc06f21
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Oct 2 17:17:15 2018 +0000

    Add more fma tests.
    
    In my review
    <https://sourceware.org/ml/libc-alpha/2018-06/msg00375.html> of a
    patch for bug 23584, I expressed concern that the proposed changes
    didn't deal with certain cases similar to the ones in the bug but
    where test coverage was missing.
    
    This patch adds such tests of fma (Inf, finite, finite) and fma
    (finite, Inf, finite) to libm-test-fma.inc.  It does *not* do anything
    to fix the bug, simply adds test coverage to provide stronger evidence
    of whether any proposed revised fix does address the cases I was
    concerned with.
    
    Tested for x86_64 and x86.
    
    	* math/libm-test-fma.inc (fma_test_data): Add more tests.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog              |    4 +
 math/libm-test-fma.inc |  193 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 197 insertions(+), 0 deletions(-)
Comment 4 Tulio Magno Quites Machado Filho 2019-01-16 12:43:30 UTC
I've confirmed these failures are caused by spurious overflows in libgcc.
Commit ecdacd34a2ac3b6d5a529ff218b29261d9d98a7a is now XFAIL'ing these entries.

I'm closing this now.

Reference:
https://www.sourceware.org/ml/libc-alpha/2019-01/msg00304.html