]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Prevent optimizing out of benchmark function call
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Fri, 17 May 2013 13:40:33 +0000 (19:10 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Fri, 17 May 2013 13:40:33 +0000 (19:10 +0530)
Resolves: #15424

The compiler would optimize the benchmark function call out of the
loop and call it only once, resulting in blazingly fast times for some
benchmarks (notably atan, sin and cos).  Mark the inputs as volatile
so that the code is forced to read again from the input for each
iteration.

ChangeLog
NEWS
benchtests/bench-modf.c
scripts/bench.pl

index 78d48048855689765ee2d0463d892558931c8412..58b87d4bc3e2c4053611bc85c4a7dbc2ab9b01c7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-17  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+       [BZ #15424]
+       * benchtests/bench-modf.c (struct args): Mark arg0 as
+       volatile.
+       * scripts/bench.pl: Mark members of struct args as volatile.
+
 2013-05-17  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
        * sysdeps/powerpc/fpu/e_hypot.c (GET_TWO_FLOAT_WORD): Fix test for
diff --git a/NEWS b/NEWS
index 86c287ff29de032dc749627d06073061675ba80d..57c7ee0a8f0cfdd9c191aeca3b728dc98a7c3d6b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,7 +17,7 @@ Version 2.18
   15086, 15160, 15214, 15221, 15232, 15234, 15283, 15285, 15287, 15304,
   15305, 15307, 15309, 15327, 15330, 15335, 15336, 15337, 15342, 15346,
   15359, 15361, 15366, 15380, 15394, 15395, 15405, 15406, 15409, 15416,
-  15418, 15419, 15423, 15426, 15429, 15442, 15448.
+  15418, 15419, 15423, 15424, 15426, 15429, 15442, 15448.
 
 * CVE-2013-0242 Buffer overrun in regexp matcher has been fixed (Bugzilla
   #15078).
index 7fae7dc6ac0b162ed1409fd7eadddd3fd51d6cae..2b50665b7e70692fb5936edb0ba790079abec88f 100644 (file)
@@ -21,7 +21,7 @@ extern double modf (double, double *);
 
 struct args
 {
-  double arg0;
+  volatile double arg0;
 } in[] =
 {
   {  42.42 },
index dcc5ead7276e6f011a02a052f8558ef5bfe10ba9..dcf13552820eba64381f3ee23bb5167e749dbe83 100755 (executable)
@@ -71,7 +71,7 @@ else {
       $decl = "$decl,";
     }
 
-    $arg_struct = "$arg_struct $arg arg$num;";
+    $arg_struct = "$arg_struct volatile $arg arg$num;";
     $bench_func = "$bench_func variants[v].in[i].arg$num";
     $decl = "$decl $arg";
     $num = $num + 1;