public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use volatile global counters in test-tgmath.c.
@ 2018-04-18 11:51 Stefan Liebler
  2018-04-18 16:05 ` Joseph Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Liebler @ 2018-04-18 11:51 UTC (permalink / raw)
  To: GNU C Library

[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

Hi,

If build with -Os on s390x, the test-tgmath fails with:
float functions not called often enough (-10000)

Within compile_testf(), the counter (count_float) is saved
before the complex functions are called.
Afterwards the saved counter differs to the current-counter.

But the tests with the complex functions do not increment count_float!
Instead count_float is saved to a register before calling totalorder
and totalordermag which both increment count_float.
The compiler is allowed to do that as totalorderf and totalordermagf
is declared with __attribute__ ((__const__)) in math/bits/mathcalls.h.

Thus this patch adjusts the global counters to be volatile.
Then count_float is saved after totalordermag.

Okay to commit?

Bye
Stefan

---
ChangeLog:

	* math/test-tgmath.c (count_double, count_float,
	count_ ldouble,	count_cdouble, count_cfloat,
	count_cldouble): Use volatile int.

[-- Attachment #2: 20180416_test-tgmath.patch --]
[-- Type: text/x-patch, Size: 1685 bytes --]

commit 03fd4e7e0fd1d2f6dedee49bdbefde7b23a644e1
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Mon Apr 16 16:55:25 2018 +0200

    Use volatile global counters in test-tgmath.c.
    
    If build with -Os on s390x, the test-tgmath fails with:
    float functions not called often enough (-10000)
    
    Within compile_testf(), the counter (count_float) is saved
    before the complex functions are called.
    Afterwards the saved counter differs to the current-counter.
    
    But the tests with the complex functions do not increment count_float!
    Instead count_float is saved to a register before calling totalorder
    and totalordermag which both increment count_float.
    The compiler is allowed to do that as totalorderf and totalordermagf
    is declared with __attribute__ ((__const__)) in math/bits/mathcalls.h.
    
    Thus this patch adjusts the global counters to be volatile.
    Then count_float is saved after totalordermag.
    
    ChangeLog:
    
    	* math/test-tgmath.c (count_double, count_float,
    	count_ ldouble,	count_cdouble, count_cfloat,
    	count_cldouble): Use volatile int.

diff --git a/math/test-tgmath.c b/math/test-tgmath.c
index 6d8e7fd..2b0787c 100644
--- a/math/test-tgmath.c
+++ b/math/test-tgmath.c
@@ -45,12 +45,12 @@ complex float fz;
 complex double dz;
 complex long double lz;
 
-int count_double;
-int count_float;
-int count_ldouble;
-int count_cdouble;
-int count_cfloat;
-int count_cldouble;
+volatile int count_double;
+volatile int count_float;
+volatile int count_ldouble;
+volatile int count_cdouble;
+volatile int count_cfloat;
+volatile int count_cldouble;
 
 #define NCALLS     134
 #define NCALLS_INT 4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Use volatile global counters in test-tgmath.c.
  2018-04-18 11:51 [PATCH] Use volatile global counters in test-tgmath.c Stefan Liebler
@ 2018-04-18 16:05 ` Joseph Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2018-04-18 16:05 UTC (permalink / raw)
  To: Stefan Liebler; +Cc: GNU C Library

On Wed, 18 Apr 2018, Stefan Liebler wrote:

> 	* math/test-tgmath.c (count_double, count_float,
> 	count_ ldouble,	count_cdouble, count_cfloat,
> 	count_cldouble): Use volatile int.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-18 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-18 11:51 [PATCH] Use volatile global counters in test-tgmath.c Stefan Liebler
2018-04-18 16:05 ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).