With -O3, in a inner loop, that iterates perhaps 10^9 times,
using
double opt[100];
for ()
for (...)
opt[i] = std::max( opt[i-1] , opt[i-2] );
is much much slower than
for ()
for (...)
opt[i] = opt[i-1]>opt[i-2]
ember 2007 16:38
To: Hicham Mouline
Cc: gcc@gcc.gnu.org
Subject: Re: g++ std::max() performance
Hicham Mouline wrote:
>Can anyone else observe this?
>
>
You are observing it on gcc4.2.x or gcc4.1.x, right? Because mainline
(would be 4.3.0) is able to optimize both exactly to the same tree