Anthony Shipman - insufficient inline optimisation? (original) (raw)

This is the mail archive of the gcc@gcc.gnu.orgmailing list for the GCC 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]

I have a C++ class and code that looks like this:

#include using namespace std;

class Z { public: Z() {} ~Z() {}

protected: int z_; };

int main(int argc, char** argv) { Z buf[100];

cout << sizeof(buf) << endl;
return 0;

}

The compiler version is 4.01 (on Fedora 4). If I compile with -O0 then the creation of buf results in a loop being generated which calls the Z() constructor 100 times.

But then if I compile with -O the constructor will be inlined. The generated machine code contains a loop which does nothing 100 times: movl $100, %eax .L11: decl %eax jne .L11

I think that the optimiser should get rid of the loop once it has got rid of the body!

Should I submit this as a bug?


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