public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Reduce floating-point difficulties in timevar.cc
@ 2023-07-21 12:11 Matthew Malcomson
  2023-07-21 12:47 ` Richard Biener
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Matthew Malcomson @ 2023-07-21 12:11 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.sandiford, rguenther

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

On some AArch64 bootstrapped builds, we were getting a flaky test
because the floating point operations in `get_time` were being fused
with the floating point operations in `timevar_accumulate`.

This meant that the rounding behaviour of our multiplication with
`ticks_to_msec` was different when used in `timer::start` and when
performed in `timer::stop`.  These extra inaccuracies led to the
testcase `g++.dg/ext/timevar1.C` being flaky on some hardware.

This change ensures those operations are not fused and hence stops the test
being flaky on that particular machine.  There is no expected change in the
generated code.
Bootstrap & regtest on AArch64 passes with no regressions.

gcc/ChangeLog:

	* timevar.cc (get_time): Make this noinline to avoid fusing
	behaviour and associated test flakyness.


N.b. I didn't know who to include as reviewer -- guessed Richard Biener as the
global reviewer that had the most contributions to this file and Richard
Sandiford since I've asked him for reviews a lot in the past.


###############     Attachment also inlined for ease of reply    ###############


diff --git a/gcc/timevar.cc b/gcc/timevar.cc
index d695297aae7f6b2a6de01a37fe86c2a232338df0..5ea4ec259e114f31f611e7105cd102f4c9552d18 100644
--- a/gcc/timevar.cc
+++ b/gcc/timevar.cc
@@ -212,6 +212,7 @@ timer::named_items::print (FILE *fp, const timevar_time_def *total)
    HAVE_WALL_TIME macros.  */
 
 static void
+__attribute__((noinline))
 get_time (struct timevar_time_def *now)
 {
   now->user = 0;




[-- Attachment #2: noinline-get-time.patch --]
[-- Type: text/plain, Size: 409 bytes --]

diff --git a/gcc/timevar.cc b/gcc/timevar.cc
index d695297aae7f6b2a6de01a37fe86c2a232338df0..5ea4ec259e114f31f611e7105cd102f4c9552d18 100644
--- a/gcc/timevar.cc
+++ b/gcc/timevar.cc
@@ -212,6 +212,7 @@ timer::named_items::print (FILE *fp, const timevar_time_def *total)
    HAVE_WALL_TIME macros.  */
 
 static void
+__attribute__((noinline))
 get_time (struct timevar_time_def *now)
 {
   now->user = 0;




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

end of thread, other threads:[~2023-08-04 10:18 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21 12:11 [PATCH] Reduce floating-point difficulties in timevar.cc Matthew Malcomson
2023-07-21 12:47 ` Richard Biener
2023-07-21 13:11   ` Matthew Malcomson
2023-07-21 13:41     ` Richard Biener
2023-07-21 13:45     ` Xi Ruoyao
2023-07-21 13:58       ` Alexander Monakov
2023-07-21 15:11         ` Xi Ruoyao
2023-07-21 15:56           ` Alexander Monakov
2023-07-21 15:24       ` Matthew Malcomson
2023-08-03 13:38   ` [PATCH] mid-end: Use integral time intervals " Matthew Malcomson
2023-08-03 14:09     ` David Malcolm
2023-08-03 14:54       ` Matthew Malcomson
2023-08-03 15:34         ` David Malcolm
2023-08-04  6:44     ` Richard Biener
2023-08-04  9:41       ` Matthew Malcomson
2023-08-04 10:18         ` Richard Biener
2023-07-21 12:49 ` [PATCH] Reduce floating-point difficulties " Xi Ruoyao
2023-07-21 17:41 ` Andrew Pinski

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).