This is the mail archive of the gcc@gcc.gnu.org mailing 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]

Question about inline optimization


I recently wrote the following code:
----------x.cpp
class C {
public:
double x, y;
};
inline double f(C a, C b) {
return a.x * b.y - a.y * b.x;
}
bool g(C a, C b) {
return f(a, b) == 0;
}
---------
Compiling with the command "g++ -O3 -S x.cpp" created a rather surprising output. (I have only GCC 3.3.3 on CRUX GNU/Linux for i686; sorry about that; maybe somebody could test it with 3.4.1)
GCC did not optimize copying variables to stack. That is, "g()" placed
the variables a.x, a.y, b.x, b.y on the stack with moves and then from the stack to fpu.
Why does it happen? This function is performance-critical in my program, so optimizing the movs could be very beneficient to me.



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