This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: [BZ #15424] Prevent optimizing out of benchmark function call


Seems straightforward, ok for me.


On 05/17/2013 09:13 AM, Siddhesh Poyarekar wrote:
> Hi,
>
> 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).  This patch marks the inputs
> as volatile so that the code is forced to read again from the input
> for each iteration.  The modf code doesn't need the change right now,
> but I've added it in any for consistency and to prevent the
> possibility of a future compiler finding an optimization opportunity
> there.
>
> OK to commit?
>
> Siddhesh
>
> 	[BZ #15424]
> 	* benchtests/bench-modf.c (struct args): Mark arg0 as
> 	volatile.
> 	* scripts/bench.pl: Mark members of struct args as volatile.
>
> diff --git a/benchtests/bench-modf.c b/benchtests/bench-modf.c
> index 7fae7dc..2b50665 100644
> --- a/benchtests/bench-modf.c
> +++ b/benchtests/bench-modf.c
> @@ -21,7 +21,7 @@ extern double modf (double, double *);
>
>  struct args
>  {
> -  double arg0;
> +  volatile double arg0;
>  } in[] =
>  {
>    {  42.42 },
> diff --git a/scripts/bench.pl b/scripts/bench.pl
> index dcc5ead..dcf1355 100755
> --- a/scripts/bench.pl
> +++ b/scripts/bench.pl
> @@ -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;
>


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