Bug 21280

Summary: [powerpc] logbl for POWER7 return incorrect results
Product: glibc Reporter: Tulio Magno Quites Machado Filho <tuliom>
Component: mathAssignee: Tulio Magno Quites Machado Filho <tuliom>
Status: RESOLVED FIXED    
Severity: normal Flags: fweimer: security-
Priority: P2    
Version: 2.25   
Target Milestone: 2.26   
Host: Target: powerpc*-linux
Build: Last reconfirmed:

Description Tulio Magno Quites Machado Filho 2017-03-20 19:53:31 UTC
The errors affect negative subnormals and values near powers of 2.

testing long double (without inline functions)
Failure: Test: logb (-min_subnorm_value)
Result:
 is:         -1.01100000000000000000000000000000e+03  -0x1.f98000000000000000000000000p+9
 should be:  -1.07400000000000000000000000000000e+03  -0x1.0c8000000000000000000000000p+10
 difference:  6.30000000000000000000000000000000e+01   0x1.f80000000000000000000000000p+5
 ulp       :  2495687119199326634196634435584.0000
 max.ulp   :  0.0000
Failure: Test: logb (0x1.ffffffffffffffp1)
Result:
 is:          2.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 ulp       :  40564819207303340847894502572032.0000
 max.ulp   :  0.0000
Failure: Test: logb (-0x1.ffffffffffffffp1)
Result:
 is:          2.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 ulp       :  40564819207303340847894502572032.0000
 max.ulp   :  0.0000
Failure: Test: logb_downward (-min_subnorm_value)
Result:
 is:         -1.01100000000000000000000000000000e+03  -0x1.f98000000000000000000000000p+9
 should be:  -1.07400000000000000000000000000000e+03  -0x1.0c8000000000000000000000000p+10
 difference:  6.30000000000000000000000000000000e+01   0x1.f80000000000000000000000000p+5
 ulp       :  2495687119199326634196634435584.0000
 max.ulp   :  0.0000
Failure: Test: logb_downward (0x1.ffffffffffffffp1)
Result:
 is:          2.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 ulp       :  40564819207303340847894502572032.0000
 max.ulp   :  0.0000
Failure: Test: logb_downward (-0x1.ffffffffffffffp1)
Result:
 is:          2.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 ulp       :  40564819207303340847894502572032.0000
 max.ulp   :  0.0000
Failure: Test: logb_towardzero (-min_subnorm_value)
Result:
 is:         -1.01100000000000000000000000000000e+03  -0x1.f98000000000000000000000000p+9
 should be:  -1.07400000000000000000000000000000e+03  -0x1.0c8000000000000000000000000p+10
 difference:  6.30000000000000000000000000000000e+01   0x1.f80000000000000000000000000p+5
 ulp       :  2495687119199326634196634435584.0000
 max.ulp   :  0.0000
Failure: Test: logb_towardzero (0x1.ffffffffffffffp1)
Result:
 is:          2.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 ulp       :  40564819207303340847894502572032.0000
 max.ulp   :  0.0000
Failure: Test: logb_towardzero (-0x1.ffffffffffffffp1)
Result:
 is:          2.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 ulp       :  40564819207303340847894502572032.0000
 max.ulp   :  0.0000
Failure: Test: logb_upward (-min_subnorm_value)
Result:
 is:         -1.01100000000000000000000000000000e+03  -0x1.f98000000000000000000000000p+9
 should be:  -1.07400000000000000000000000000000e+03  -0x1.0c8000000000000000000000000p+10
 difference:  6.30000000000000000000000000000000e+01   0x1.f80000000000000000000000000p+5
 ulp       :  2495687119199326634196634435584.0000
 max.ulp   :  0.0000
Failure: Test: logb_upward (0x1.ffffffffffffffp1)
Result:
 is:          2.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 ulp       :  40564819207303340847894502572032.0000
 max.ulp   :  0.0000
Failure: Test: logb_upward (-0x1.ffffffffffffffp1)
Result:
 is:          2.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 ulp       :  40564819207303340847894502572032.0000
 max.ulp   :  0.0000

Test suite completed:
  120 test cases plus 116 tests for exception flags and
    116 tests for errno executed.
  12 errors occurred.
Comment 1 Sourceware Commits 2017-04-28 22:48:21 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  c064f6a613844181f411aabb2662384a6aefb69e (commit)
      from  2f7f3cd8cd302bb10908c86f3f7b349df0a78e6a (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=c064f6a613844181f411aabb2662384a6aefb69e

commit c064f6a613844181f411aabb2662384a6aefb69e
Author: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Date:   Fri Apr 28 19:45:52 2017 -0300

    powerpc: Fix logbl on power7 [BZ# 21280]
    
     1. Fix the results for negative subnormals by ignoring the signal when
        normalizing the value.
     2. Fix the output when the high part is a power of 2 and the low part
        is a nonzero number with opposite sign.  This fix is based on commit
        380bd0fd2418f8988217de950f8b8ff18af0cb2b.
    
    After applying this patch, logbl() tests pass cleanly on POWER >= 7.
    
    Tested on powerpc, powerpc64 and powerpc64le
    
    	[BZ #21280]
    	* sysdeps/powerpc/power7/fpu/s_logbl.c (__logbl): Ignore the
    	signal of subnormals and adjust the exponent of power of 2 down
    	when low part has opposite sign.

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

Summary of changes:
 ChangeLog                            |    7 +++++++
 sysdeps/powerpc/power7/fpu/s_logbl.c |   24 ++++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)
Comment 2 Tulio Magno Quites Machado Filho 2017-04-28 22:49:38 UTC
Fixed on glibc 2.26 with commit ID c064f6a613844181f411aabb2662384a6aefb69e.
Comment 3 Sourceware Commits 2017-08-02 13:32:14 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, release/2.25/master has been updated
       via  da3e97f94c80c5d05c0d999e87179aad35f7e975 (commit)
      from  0edeadc0d396aa713b808ae50a0058aca5d3837e (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=da3e97f94c80c5d05c0d999e87179aad35f7e975

commit da3e97f94c80c5d05c0d999e87179aad35f7e975
Author: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Date:   Fri Apr 28 19:45:52 2017 -0300

    powerpc: Fix logbl on power7 [BZ# 21280]
    
     1. Fix the results for negative subnormals by ignoring the signal when
        normalizing the value.
     2. Fix the output when the high part is a power of 2 and the low part
        is a nonzero number with opposite sign.  This fix is based on commit
        380bd0fd2418f8988217de950f8b8ff18af0cb2b.
    
    After applying this patch, logbl() tests pass cleanly on POWER >= 7.
    
    Tested on powerpc, powerpc64 and powerpc64le
    
    	[BZ #21280]
    	* sysdeps/powerpc/power7/fpu/s_logbl.c (__logbl): Ignore the
    	signal of subnormals and adjust the exponent of power of 2 down
    	when low part has opposite sign.
    
    (cherry picked from commit c064f6a613844181f411aabb2662384a6aefb69e)

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

Summary of changes:
 ChangeLog                            |    7 +++++++
 sysdeps/powerpc/power7/fpu/s_logbl.c |   24 ++++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)