[PATCHv3,03/11] Refactor M_ macros defined in libm-test.inc
diff mbox

Message ID 25f81e70-5dba-2244-f759-a0f2f2af3e52@linux.vnet.ibm.com
State New
Headers show

Commit Message

Paul E. Murphy May 27, 2016, 3:45 p.m. UTC
On 05/26/2016 06:14 PM, Joseph Myers wrote:
> On Thu, 26 May 2016, Paul E. Murphy wrote:
> 
>> +/* (pi * 3 * ln(10) / 4 */
>> +#define lit_pi_3_m_ln10_m_4_d	LIT (1.023282265381381010614337719073516828)
> 
> You're missing a ')' in the comment.  And, the comment, and thus the macro 
> name according to your scheme, are inaccurate; this one involves dividing 
> by ln(10), not multiplying by it (all the ln(10) ones are for clog10 
> expectations).
> 

Very wrong indeed.  Let me fix it with:

+/* pi * 3 / (4 * ln(10)) */
+#define lit_pi_3_m_4_ln10_m_d  LIT (1.023282265381381010614337719073516828)

Likewise, the updated comment above all of them read poorly.

+/* Various constants derived from pi.  We must supply them precalculated for
+   accuracy.  They are written as a series of postfix operations to keep
+   them concise yet somewhat readable.  */

The updated patch is attached.  I'd prefer to get this approved and committed
before committing the other M_ -> lit_ changes.

Comments

Joseph Myers May 27, 2016, 4:08 p.m. UTC | #1
On Fri, 27 May 2016, Paul E. Murphy wrote:

> The updated patch is attached.  I'd prefer to get this approved and committed
> before committing the other M_ -> lit_ changes.

You need to update this for my removal of M_PI_6l as unused.  OK with that 
change.
Paul E. Murphy May 27, 2016, 5:12 p.m. UTC | #2
On 05/27/2016 11:08 AM, Joseph Myers wrote:
> On Fri, 27 May 2016, Paul E. Murphy wrote:
> 
>> The updated patch is attached.  I'd prefer to get this approved and committed
>> before committing the other M_ -> lit_ changes.
> 
> You need to update this for my removal of M_PI_6l as unused.  OK with that 
> change.
> 

Removed and committed as 135d1c7.

Patch
diff mbox

From 6561a219b9e6c67e49a5154f188004ae1552b46c Mon Sep 17 00:00:00 2001
From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>
Date: Fri, 20 May 2016 09:46:39 -0500
Subject: [PATCH 1/9] Refactor M_ macros defined in libm-test.inc

These are local to the test suite.  Rename them as a macro starting
with lit_pi and a series of postfix operations to give us a constant
starting with lit_pi.

The lit prefix is intended to enable easy substitutions via
gen-test-libm.pl if needed.

	* libm-test.inc (M_PI_6l) Rename to
	(lit_pi_6_d): New Macro.
	(M_PI_34l): Rename to
	(lit_pi_3_m_4_d): New Macro.
	(M_PI_34_LOG10El): Rename to
	(lit_pi_3_m_4_ln10_m_d): New Macro.
	(M_PI2_LOG10El): Rename to
	(lit_pi_2_ln10_m_d):  New Macro.
	(M_PI4_LOG10El): Rename to
	(lit_pi_4_ln10_m_d):  New Macro.
	(M_PI_LOG10El): Rename to
	(lit_pi_ln10_d):  New Macro.
---
 math/libm-test.inc | 77 ++++++++++++++++++++++++++++++------------------------
 1 file changed, 43 insertions(+), 34 deletions(-)

diff --git a/math/libm-test.inc b/math/libm-test.inc
index 9c75a01..c27f3cd 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -305,13 +305,22 @@  struct ulp_data
 # define TEST_COND_x86		0
 #endif
 
-/* Various constants (we must supply them precalculated for accuracy).  */
-#define M_PI_6l			.52359877559829887307710723054658383L
-#define M_PI_34l		2.356194490192344928846982537459627163L	/* 3*pi/4 */
-#define M_PI_34_LOG10El		1.023282265381381010614337719073516828L
-#define M_PI2_LOG10El		0.682188176920920673742891812715677885L
-#define M_PI4_LOG10El		0.341094088460460336871445906357838943L
-#define M_PI_LOG10El		1.364376353841841347485783625431355770L
+/* Various constants derived from pi.  We must supply them precalculated for
+   accuracy.  They are written as a series of postfix operations to keep
+   them concise yet somewhat readable.  */
+
+/* pi / 6 */
+#define lit_pi_6_d		LIT (.52359877559829887307710723054658383)
+/* (pi * 3) / 4 */
+#define lit_pi_3_m_4_d		LIT (2.356194490192344928846982537459627163)
+/* pi * 3 / (4 * ln(10)) */
+#define lit_pi_3_m_4_ln10_m_d	LIT (1.023282265381381010614337719073516828)
+/* pi / (2 * ln(10)) */
+#define lit_pi_2_ln10_m_d	LIT (0.682188176920920673742891812715677885)
+/* pi / (4 * ln(10)) */
+#define lit_pi_4_ln10_m_d	LIT (0.341094088460460336871445906357838943)
+/* pi / ln(10) */
+#define lit_pi_ln10_d		LIT (1.364376353841841347485783625431355770)
 
 #define ulps_file_name "ULPs"	/* Name of the ULPs file.  */
 static FILE *ulps_file;		/* File to document difference.  */
@@ -1989,8 +1998,8 @@  static const struct test_ff_f_data atan2_test_data[] =
 
     TEST_ff_f (atan2, plus_infty, plus_infty, M_PI_4l, ERRNO_UNCHANGED),
     TEST_ff_f (atan2, minus_infty, plus_infty, -M_PI_4l, ERRNO_UNCHANGED),
-    TEST_ff_f (atan2, plus_infty, minus_infty, M_PI_34l, ERRNO_UNCHANGED),
-    TEST_ff_f (atan2, minus_infty, minus_infty, -M_PI_34l, ERRNO_UNCHANGED),
+    TEST_ff_f (atan2, plus_infty, minus_infty, lit_pi_3_m_4_d, ERRNO_UNCHANGED),
+    TEST_ff_f (atan2, minus_infty, minus_infty, -lit_pi_3_m_4_d, ERRNO_UNCHANGED),
     TEST_ff_f (atan2, qnan_value, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_ff_f (atan2, qnan_value, -qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_ff_f (atan2, -qnan_value, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
@@ -2082,8 +2091,8 @@  static const struct test_c_c_data cacos_test_data[] =
     TEST_c_c (cacos, minus_zero, minus_zero, M_PI_2l, 0.0),
     TEST_c_c (cacos, 0, minus_zero, M_PI_2l, 0.0),
 
-    TEST_c_c (cacos, minus_infty, plus_infty, M_PI_34l, minus_infty),
-    TEST_c_c (cacos, minus_infty, minus_infty, M_PI_34l, plus_infty),
+    TEST_c_c (cacos, minus_infty, plus_infty, lit_pi_3_m_4_d, minus_infty),
+    TEST_c_c (cacos, minus_infty, minus_infty, lit_pi_3_m_4_d, plus_infty),
 
     TEST_c_c (cacos, plus_infty, plus_infty, M_PI_4l, minus_infty),
     TEST_c_c (cacos, plus_infty, minus_infty, M_PI_4l, plus_infty),
@@ -2769,8 +2778,8 @@  static const struct test_c_c_data cacosh_test_data[] =
     TEST_c_c (cacosh, minus_zero, 0, 0.0, M_PI_2l),
     TEST_c_c (cacosh, 0, minus_zero, 0.0, -M_PI_2l),
     TEST_c_c (cacosh, minus_zero, minus_zero, 0.0, -M_PI_2l),
-    TEST_c_c (cacosh, minus_infty, plus_infty, plus_infty, M_PI_34l),
-    TEST_c_c (cacosh, minus_infty, minus_infty, plus_infty, -M_PI_34l),
+    TEST_c_c (cacosh, minus_infty, plus_infty, plus_infty, lit_pi_3_m_4_d),
+    TEST_c_c (cacosh, minus_infty, minus_infty, plus_infty, -lit_pi_3_m_4_d),
 
     TEST_c_c (cacosh, plus_infty, plus_infty, plus_infty, M_PI_4l),
     TEST_c_c (cacosh, plus_infty, minus_infty, plus_infty, -M_PI_4l),
@@ -3472,9 +3481,9 @@  static const struct test_c_f_data carg_test_data[] =
 
     TEST_c_f (carg, plus_infty, minus_infty, -M_PI_4l),
 
-    TEST_c_f (carg, minus_infty, plus_infty, M_PI_34l),
+    TEST_c_f (carg, minus_infty, plus_infty, lit_pi_3_m_4_d),
 
-    TEST_c_f (carg, minus_infty, minus_infty, -M_PI_34l),
+    TEST_c_f (carg, minus_infty, minus_infty, -lit_pi_3_m_4_d),
 
     TEST_c_f (carg, qnan_value, qnan_value, qnan_value),
 
@@ -6236,8 +6245,8 @@  static const struct test_c_c_data clog_test_data[] =
     TEST_c_c (clog, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION),
     TEST_c_c (clog, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION),
 
-    TEST_c_c (clog, minus_infty, plus_infty, plus_infty, M_PI_34l),
-    TEST_c_c (clog, minus_infty, minus_infty, plus_infty, -M_PI_34l),
+    TEST_c_c (clog, minus_infty, plus_infty, plus_infty, lit_pi_3_m_4_d),
+    TEST_c_c (clog, minus_infty, minus_infty, plus_infty, -lit_pi_3_m_4_d),
 
     TEST_c_c (clog, plus_infty, plus_infty, plus_infty, M_PI_4l),
     TEST_c_c (clog, plus_infty, minus_infty, plus_infty, -M_PI_4l),
@@ -6291,30 +6300,30 @@  clog_test (void)
 
 static const struct test_c_c_data clog10_test_data[] =
   {
-    TEST_c_c (clog10, minus_zero, 0, minus_infty, M_PI_LOG10El, DIVIDE_BY_ZERO_EXCEPTION),
-    TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -M_PI_LOG10El, DIVIDE_BY_ZERO_EXCEPTION),
+    TEST_c_c (clog10, minus_zero, 0, minus_infty, lit_pi_ln10_d, DIVIDE_BY_ZERO_EXCEPTION),
+    TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -lit_pi_ln10_d, DIVIDE_BY_ZERO_EXCEPTION),
 
     TEST_c_c (clog10, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION),
     TEST_c_c (clog10, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION),
 
-    TEST_c_c (clog10, minus_infty, plus_infty, plus_infty, M_PI_34_LOG10El),
+    TEST_c_c (clog10, minus_infty, plus_infty, plus_infty, lit_pi_3_m_4_ln10_m_d),
 
-    TEST_c_c (clog10, plus_infty, plus_infty, plus_infty, M_PI4_LOG10El),
-    TEST_c_c (clog10, plus_infty, minus_infty, plus_infty, -M_PI4_LOG10El),
+    TEST_c_c (clog10, plus_infty, plus_infty, plus_infty, lit_pi_4_ln10_m_d),
+    TEST_c_c (clog10, plus_infty, minus_infty, plus_infty, -lit_pi_4_ln10_m_d),
 
-    TEST_c_c (clog10, 0, plus_infty, plus_infty, M_PI2_LOG10El),
-    TEST_c_c (clog10, 3, plus_infty, plus_infty, M_PI2_LOG10El),
-    TEST_c_c (clog10, minus_zero, plus_infty, plus_infty, M_PI2_LOG10El),
-    TEST_c_c (clog10, -3, plus_infty, plus_infty, M_PI2_LOG10El),
-    TEST_c_c (clog10, 0, minus_infty, plus_infty, -M_PI2_LOG10El),
-    TEST_c_c (clog10, 3, minus_infty, plus_infty, -M_PI2_LOG10El),
-    TEST_c_c (clog10, minus_zero, minus_infty, plus_infty, -M_PI2_LOG10El),
-    TEST_c_c (clog10, -3, minus_infty, plus_infty, -M_PI2_LOG10El),
+    TEST_c_c (clog10, 0, plus_infty, plus_infty, lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, 3, plus_infty, plus_infty, lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, minus_zero, plus_infty, plus_infty, lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, -3, plus_infty, plus_infty, lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, 0, minus_infty, plus_infty, -lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, 3, minus_infty, plus_infty, -lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, minus_zero, minus_infty, plus_infty, -lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, -3, minus_infty, plus_infty, -lit_pi_2_ln10_m_d),
 
-    TEST_c_c (clog10, minus_infty, 0, plus_infty, M_PI_LOG10El),
-    TEST_c_c (clog10, minus_infty, 1, plus_infty, M_PI_LOG10El),
-    TEST_c_c (clog10, minus_infty, minus_zero, plus_infty, -M_PI_LOG10El),
-    TEST_c_c (clog10, minus_infty, -1, plus_infty, -M_PI_LOG10El),
+    TEST_c_c (clog10, minus_infty, 0, plus_infty, lit_pi_ln10_d),
+    TEST_c_c (clog10, minus_infty, 1, plus_infty, lit_pi_ln10_d),
+    TEST_c_c (clog10, minus_infty, minus_zero, plus_infty, -lit_pi_ln10_d),
+    TEST_c_c (clog10, minus_infty, -1, plus_infty, -lit_pi_ln10_d),
 
     TEST_c_c (clog10, plus_infty, 0, plus_infty, 0.0),
     TEST_c_c (clog10, plus_infty, 1, plus_infty, 0.0),
-- 
2.4.11