This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/30545] New: Why does optimizer not move exp() out of loop
- From: "georg dot viehoever at web dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jan 2007 17:01:24 -0000
- Subject: [Bug rtl-optimization/30545] New: Why does optimizer not move exp() out of loop
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hi,
I wonder why gcc does not move the constant exp() call from the inner loop to
the outer loop. Should I use different optimization settings?
Georg
Checked with g++ -O3 -S t.cpp; emacs t.S
t.cpp:
#include <cmath>
#include <iostream>
int main()
{
for (int i=0; i<10;++i)
{
for (int j=0; j<2;++j)
{
// this is constant for both runs of this loop
double res=exp(i);
std::cout<<"exp("<<i<<")="<<res<<std::endl;
}
}
return 0;
}
--
Summary: Why does optimizer not move exp() out of loop
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: georg dot viehoever at web dot de
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30545