Bug 229501

Summary: [libm] Reduce diff between src/e_j0.c and src/e_j0f.c
Product: Base System Reporter: sgk
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: pfg
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Use literal constants
none
Use literal constants none

Description sgk 2018-07-03 19:04:27 UTC
Created attachment 194865 [details]
Use literal constants

The attached diff reduces the diff between src/e_j0.c and src/e_j0f.c.
Specifically, where possible it uses literal integer constants to
remove the need for casting a double literal constant to a float, and
it introduces 'static const <type> qrtr = 0.25' and 'static const <type>
eighth = 0.125' to eliminate the need for casting doubles to floats.
Exhaustive testing of j0f(x) in the domain [0,1e+30) shows no differences.

While here convert a sentence fragment in a comment to a sentence.
Comment 1 Pedro F. Giffuni freebsd_committer freebsd_triage 2019-01-08 15:23:42 UTC
Looking at the patch:
--- src/e_j0f.c (revision 342861)
+++ src/e_j0f.c (working copy)
@@ -42,7 +42,7 @@
 S03  =  5.1354652442e-07, /* 0x3509daa6 */
 S04  =  1.1661400734e-09; /* 0x30a045e8 */
 
-static const float zero = 0.0;
+static const float zero = 0, qrtr = 0.25;
 
 float
 __ieee754_j0f(float x)
...

It is probably old school but I would  prefer we still use 0.0 for float.
Comment 2 Pedro F. Giffuni freebsd_committer freebsd_triage 2019-01-08 15:39:45 UTC
Created attachment 200917 [details]
Use literal constants

Small variation of the patch, using 0.0 and 1.0 where pertinent.
Comment 3 Pedro F. Giffuni freebsd_committer freebsd_triage 2019-01-14 15:08:44 UTC
Comment on attachment 200917 [details]
Use literal constants

According to bde@:

It's silly to use 0.0 for float in some contexts when the main point of
the patch is to use integer constants that will be converted to float
instead of explicit float constants.  0.0 isn't even a float constant,
but is converted to one before assignment to a float variable.

Also, static initialization to any type of 0 is redundant.
Comment 4 commit-hook freebsd_committer freebsd_triage 2019-01-14 15:49:44 UTC
A commit references this bug:

Author: pfg
Date: Mon Jan 14 15:48:35 UTC 2019
New revision: 343023
URL: https://svnweb.freebsd.org/changeset/base/343023

Log:
  msun: reduce diff between src/e_j0.c and src/e_j0f.c

  PR:	229501
  MFC after:	1 week

Changes:
  head/lib/msun/src/e_j0.c
  head/lib/msun/src/e_j0f.c
Comment 5 commit-hook freebsd_committer freebsd_triage 2019-01-21 14:53:38 UTC
A commit references this bug:

Author: pfg
Date: Mon Jan 21 14:52:49 UTC 2019
New revision: 343256
URL: https://svnweb.freebsd.org/changeset/base/343256

Log:
  MFC r343023:
  msun: reduce diff between src/e_j0.c and src/e_j0f.c

  PR:	229501

Changes:
_U  stable/12/
  stable/12/lib/msun/src/e_j0.c
  stable/12/lib/msun/src/e_j0f.c
Comment 6 commit-hook freebsd_committer freebsd_triage 2019-01-21 14:54:42 UTC
A commit references this bug:

Author: pfg
Date: Mon Jan 21 14:54:01 UTC 2019
New revision: 343257
URL: https://svnweb.freebsd.org/changeset/base/343257

Log:
  MFC r343023:
  msun: reduce diff between src/e_j0.c and src/e_j0f.c

  PR:	229501

Changes:
_U  stable/11/
  stable/11/lib/msun/src/e_j0.c
  stable/11/lib/msun/src/e_j0f.c
Comment 7 commit-hook freebsd_committer freebsd_triage 2019-01-21 14:55:45 UTC
A commit references this bug:

Author: pfg
Date: Mon Jan 21 14:55:10 UTC 2019
New revision: 343258
URL: https://svnweb.freebsd.org/changeset/base/343258

Log:
  MFC r343023:
  msun: reduce diff between src/e_j0.c and src/e_j0f.c

  PR:	229501

Changes:
_U  stable/10/
  stable/10/lib/msun/src/e_j0.c
  stable/10/lib/msun/src/e_j0f.c
Comment 8 Pedro F. Giffuni freebsd_committer freebsd_triage 2019-01-21 14:57:03 UTC
Committed, thanks !