In the code I noticed a lot of btScalar const references. Since btScalar is nothing more than a define to a built-in type (in this case float). The problem with const references in combination with these types, is that the resulting assembly can contains useless loads and stores.
Consider this example:
Code: Select all
btVector3::btVector3(const btScalar& p_x, const btScalar& p_y, const btScalar& p_z)
{
m_floats[0] = p_x;
m_floats[1] = p_y;
m_floats[2] = p_z;
m_floats[3] = btScalar(0.);
}
Code: Select all
lfs fp3,0(r4)
lfs fp2,0(r5)
lfs fp1,0(r6)
lfs fp0,-30496(r2)
stfs fp3,0(r3)
stfs fp2,4(r3)
stfs fp1,8(r3)
stfs fp0,12(r3)
blr
Code: Select all
lfs fp0,-30496(r2)
stfs fp1,0(r3)
stfs fp2,4(r3)
stfs fp3,8(r3)
stfs fp0,12(r3)
blr
When inlining is used, the compiler probably produces almost the same code in both cases. However as we already noticed in our Wii game, the compiler often fails to inline if the code is too complex. And this unfortunately occurs frequently in the bullet code.
Anyhow, perhaps it is a good idea to remove all those const references from at least all speed critical code (e.g., btVector3)
Cheers