This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Question about inline optimization
- From: Arkadiusz Pawlik <apawlik at V-LO dot krakow dot pl>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 6 Aug 2004 17:05:18 +0200 (CEST)
- Subject: 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.