This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] c11-atomic-exec-5: Avoid dead code where LDBL_MANT_DIG is 106


Hi,

 Commit 216437 missed a part of Adhemerval's original change that made 
`long_double_add_overflow', `complex_long_double_add_overflow', 
`long_double_sub_overflow' and `complex_long_double_sub_overflow' tests 
consistently defined only if called.  These tests are now only made under 
the `LDBL_MANT_DIG != 106' condition, otherwise there is no need to 
provide definitions that become dead code.

 Here's the missing part, I have verified the source still builds after 
the change manually with:

$ gcc -U__LDBL_MANT_DIG__ -D__LDBL_MANT_DIG__=113 -Wunused-function -std=c11 -pedantic-errors -pthread -D_POSIX_C_SOURCE=200809L -lm -latomic -o c11-atomic-exec-5 c11-atomic-exec-5.c

and:

$ gcc -U__LDBL_MANT_DIG__ -D__LDBL_MANT_DIG__=106 -Wunused-function -std=c11 -pedantic-errors -pthread -D_POSIX_C_SOURCE=200809L -lm -latomic -o c11-atomic-exec-5 c11-atomic-exec-5.c

It also passed regression testing with the powerpc-gnu-linux target and my 
usual multilibs that have LDBL_MANT_DIG set to 106, which is the only case 
this change really affects.

 Without this change I get this instead:

$ gcc -U__LDBL_MANT_DIG__ -D__LDBL_MANT_DIG__=113 -Wunused-function -std=c11 -pedantic-errors -pthread -D_POSIX_C_SOURCE=200809L -lm -latomic -o c11-atomic-exec-5 c11-atomic-exec-5.c
$

(OK), and:

$ gcc -U__LDBL_MANT_DIG__ -D__LDBL_MANT_DIG__=106 -Wunused-function -std=c11 -pedantic-errors -pthread -D_POSIX_C_SOURCE=200809L -lm -latomic -o c11-atomic-exec-5 c11-atomic-exec-5.c
c11-atomic-exec-5.c:62:1: warning: 'test_main_long_double_add_overflow' definedbut not used [-Wunused-function]
 test_main_##NAME (void)       \
 ^
c11-atomic-exec-5.c:334:1: note: in expansion of macro 'TEST_FUNCS'
 TEST_FUNCS (long_double_add_overflow, long double, , += LDBL_MAX, 0,
 ^
c11-atomic-exec-5.c:62:1: warning: 'test_main_complex_long_double_add_overflow'defined but not used [-Wunused-function]
 test_main_##NAME (void)       \
 ^
c11-atomic-exec-5.c:352:1: note: in expansion of macro 'TEST_FUNCS'
 TEST_FUNCS (complex_long_double_add_overflow, _Complex long double, , += LDBL_MAX, 0,
 ^
c11-atomic-exec-5.c:62:1: warning: 'test_main_long_double_sub_overflow' definedbut not used [-Wunused-function]
 test_main_##NAME (void)       \
 ^
c11-atomic-exec-5.c:358:1: note: in expansion of macro 'TEST_FUNCS'
 TEST_FUNCS (long_double_sub_overflow, long double, , -= LDBL_MAX, 0,
 ^
c11-atomic-exec-5.c:62:1: warning: 'test_main_complex_long_double_sub_overflow'defined but not used [-Wunused-function]
 test_main_##NAME (void)       \
 ^
c11-atomic-exec-5.c:376:1: note: in expansion of macro 'TEST_FUNCS'
 TEST_FUNCS (complex_long_double_sub_overflow, _Complex long double, , -= LDBL_MAX, 0,
 ^
$

(not quite so).

 This also wraps the definitions of the `NOT_LDBL_EPSILON_2' and 
`NOT_MINUS_LDBL_EPSILON_2' macros into this condition, but these aren't 
referred to if `LDBL_MANT_DIG' is 106 either.

 No changes compared to original code so all credit goes to Adhemerval.  
OK to apply?

2014-10-24  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>

	gcc/testsuite/
	* gcc.dg/atomic/c11-atomic-exec-5.c 
	(test_main_long_double_add_overflow): Only actually define if
	LDBL_MANT_DIG != 106.
	(test_main_complex_long_double_add_overflow): Likewise.
	(test_main_long_double_sub_overflow): Likewise.
	(test_main_complex_long_double_sub_overflow): Likewise.

	(NOT_LDBL_EPSILON_2): Likewise.
	(NOT_MINUS_LDBL_EPSILON_2): Likewise.

  Maciej

gcc-r216437-azanella-rs6000-atomic-assign-expand-env-update.diff
Index: gcc-fsf-trunk-quilt/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-5.c
===================================================================
--- gcc-fsf-trunk-quilt.orig/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-5.c	2014-10-22 21:59:45.788954624 +0100
+++ gcc-fsf-trunk-quilt/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-5.c	2014-10-22 21:59:15.788143775 +0100
@@ -331,11 +331,11 @@ TEST_FUNCS (complex_double_div_overflow,
 TEST_FUNCS (long_double_add_invalid, long double, , += __builtin_infl (), 0,
 	    0, __builtin_isinf, 0,
 	    -__builtin_infl (), FE_INVALID)
+#if LDBL_MANT_DIG != 106
 TEST_FUNCS (long_double_add_overflow, long double, , += LDBL_MAX, 0,
 	    LDBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT,
 	    0, 0)
 #define NOT_LDBL_EPSILON_2(X) ((X) != LDBL_EPSILON / 2)
-#if LDBL_MANT_DIG != 106
 TEST_FUNCS (long_double_add_inexact, long double, , += LDBL_EPSILON / 2, 0,
 	    1.0L, NOT_LDBL_EPSILON_2, FE_INEXACT,
 	    0, 0)
@@ -348,18 +348,18 @@ TEST_FUNCS (long_double_preinc_inexact, 
 TEST_FUNCS (long_double_postinc_inexact, long double, , ++, 0,
 	    LDBL_EPSILON / 2, NOT_MINUS_1, FE_INEXACT,
 	    -1, 0)
-#endif
 TEST_FUNCS (complex_long_double_add_overflow, _Complex long double, , += LDBL_MAX, 0,
 	    LDBL_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT,
 	    0, 0)
+#endif
 TEST_FUNCS (long_double_sub_invalid, long double, , -= __builtin_infl (), 0,
 	    0, __builtin_isinf, 0,
 	    __builtin_infl (), FE_INVALID)
+#if LDBL_MANT_DIG != 106
 TEST_FUNCS (long_double_sub_overflow, long double, , -= LDBL_MAX, 0,
 	    -LDBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT,
 	    0, 0)
 #define NOT_MINUS_LDBL_EPSILON_2(X) ((X) != -LDBL_EPSILON / 2)
-#if LDBL_MANT_DIG != 106
 TEST_FUNCS (long_double_sub_inexact, long double, , -= LDBL_EPSILON / 2, 0,
 	    -1.0L, NOT_MINUS_LDBL_EPSILON_2, FE_INEXACT,
 	    0, 0)
@@ -372,10 +372,10 @@ TEST_FUNCS (long_double_predec_inexact, 
 TEST_FUNCS (long_double_postdec_inexact, long double, , --, 0,
 	    -LDBL_EPSILON / 2, NOT_1, FE_INEXACT,
 	    1, 0)
-#endif
 TEST_FUNCS (complex_long_double_sub_overflow, _Complex long double, , -= LDBL_MAX, 0,
 	    -LDBL_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT,
 	    0, 0)
+#endif
 TEST_FUNCS (long_double_mul_invalid, long double, , *= __builtin_infl (), 0,
 	    __builtin_infl (), __builtin_isinf, 0,
 	    0, FE_INVALID)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]