don't let gcc automaticly inline functions but make gcc inline bigger

functions when told to. also make gcc warn if it can't inline a function.

Explicitly inline several functions (including moving VectorNormalize to
mathlib.h so it /can/ be) resulting in a 5.5% speedup for spam2 (88 to 92
fps)
This commit is contained in:
Bill Currie 2003-08-11 06:05:07 +00:00
parent b88d275994
commit 7ead5a91f8
12 changed files with 62 additions and 61 deletions

View file

@ -1312,7 +1312,7 @@ if test "x$optimize" = xyes; then
CC_SUB=$3
IFS=" "
AC_MSG_RESULT($CCVER)
heavy="-O3 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations"
heavy="-O2 -frename-registers -finline-limit=32000 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations"
light="-O2"
AC_ARG_ENABLE(strict-aliasing,
[ --enable-strict-aliasing enable the -fstrict-aliasing ooption of gcc])
@ -1472,7 +1472,7 @@ AC_ARG_ENABLE(Werror,
dnl We want warnings, lots of warnings...
if test "x$GCC" = "xyes"; then
if test "x$enable_Werror" $cvs_def_enabled; then
CFLAGS="$CFLAGS -Wall -Werror -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations"
CFLAGS="$CFLAGS -Wall -Werror -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline"
else
CFLAGS="$CFLAGS -Wall"
fi

View file

@ -95,7 +95,6 @@ void _VectorMA (const vec3_t veca, float scale, const vec3_t vecb,
void _VectorScale (const vec3_t in, vec_t scale, vec3_t out);
void _VectorSubtract (const vec3_t veca, const vec3_t vecb, vec3_t out);
void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross);
float VectorNormalize (vec3_t v); // returns vector length
vec_t _VectorNormalize (vec3_t v); // returns vector length
void VectorInverse (vec3_t v);
int Q_log2(int val);
@ -141,6 +140,7 @@ void RotatePointAroundVector (vec3_t dst, const vec3_t axis,
extern mplane_t frustum[4];
extern inline qboolean R_CullBox (const vec3_t mins, const vec3_t maxs);
extern inline qboolean R_CullSphere (const vec3_t origin, const float radius);
extern inline float VectorNormalize (vec3_t v); // returns vector length
#ifndef IMPLEMENT_R_Cull
extern inline
#endif
@ -173,4 +173,26 @@ R_CullSphere (const vec3_t origin, const float radius)
return false;
}
#ifndef IMPLEMENT_VectorNormalize
extern inline
#endif
float
VectorNormalize (vec3_t v)
{
float length;
length = DotProduct (v, v);
if (length) {
float ilength;
length = sqrt (length);
ilength = 1.0 / length;
v[0] *= ilength;
v[1] *= ilength;
v[2] *= ilength;
}
return length;
}
#endif // __mathlib_h

View file

@ -594,7 +594,7 @@ pr_class_pose_as (progs_t *pr)
PR_RunError (pr, "%s, not implemented", __FUNCTION__);
}
static inline pr_id_t *
static inline pr_id_t *
class_create_instance (progs_t *pr, pr_class_t *class)
{
int size = class->instance_size * sizeof (pr_type_t);

View file

@ -76,7 +76,7 @@ int stripcount;
int strip_size;
static void
static inline void
alloc_used (int size)
{
if (size <= used_size)
@ -88,7 +88,7 @@ alloc_used (int size)
used_size = size;
}
static void
static inline void
add_command (int cmd)
{
if (numcommands + 1 > commands_size) {
@ -100,7 +100,7 @@ add_command (int cmd)
commands[numcommands++] = cmd;
}
static void
static inline void
add_vertex (int vert)
{
if (numorder + 1 > vertexorder_size) {
@ -112,7 +112,7 @@ add_vertex (int vert)
vertexorder[numorder++] = vert;
}
static void
static inline void
add_strip (int vert, int tri)
{
if (stripcount + 1 > strip_size) {

View file

@ -135,8 +135,7 @@ Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int *pskinindex)
void
Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
{
byte *p;
int i, j, len, size, version, numframes, start, end, total;
int i, j, size, version, numframes, start, end, total;
dtriangle_t *pintriangles;
daliasframetype_t *pframetype;
daliasskintype_t *pskintype;
@ -151,8 +150,7 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
extra = 1; // extra precision bytes
CRC_Init (&crc);
for (len = qfs_filesize, p = buffer; len; len--, p++)
CRC_ProcessByte (&crc, *p);
CRC_ProcessBlock (buffer, &crc, qfs_filesize);
start = Hunk_LowMark ();

View file

@ -41,6 +41,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include <math.h>
#define IMPLEMENT_R_Cull
#define IMPLEMENT_VectorNormalize
#include "QF/mathlib.h"
#include "QF/qtypes.h"
@ -439,25 +440,6 @@ _VectorLength (const vec3_t v)
return length;
}
float
VectorNormalize (vec3_t v)
{
float length;
length = DotProduct (v, v);
if (length) {
float ilength;
length = sqrt (length);
ilength = 1.0 / length;
v[0] *= ilength;
v[1] *= ilength;
v[2] *= ilength;
}
return length;
}
vec_t
_VectorNormalize (vec3_t v)
{

View file

@ -563,7 +563,6 @@ typedef struct cache_system_s {
cache_system_t cache_head;
int cache_writelock;
static void *Cache_RealCheck (cache_user_t *c);
static cache_system_t *Cache_TryAlloc (int size, qboolean nobottom);
static void Cache_RealFree (cache_user_t *c);
static void Cache_Profile (void);
@ -652,7 +651,7 @@ Cache_FreeHigh (int new_high_hunk)
#endif
}
static void
static inline void
Cache_UnlinkLRU (cache_system_t * cs)
{
if (!cs->lru_next || !cs->lru_prev)
@ -664,7 +663,7 @@ Cache_UnlinkLRU (cache_system_t * cs)
cs->lru_prev = cs->lru_next = NULL;
}
static void
static inline void
Cache_MakeLRU (cache_system_t * cs)
{
if (cs->lru_next || cs->lru_prev)
@ -882,18 +881,7 @@ Cache_RealFree (cache_user_t *c)
#endif
}
void *
Cache_Check (cache_user_t *c)
{
void *mem;
CACHE_WRITE_LOCK;
mem = Cache_RealCheck (c);
CACHE_WRITE_UNLOCK;
return mem;
}
static void *
static inline void *
Cache_RealCheck (cache_user_t *c)
{
cache_system_t *cs;
@ -910,6 +898,17 @@ Cache_RealCheck (cache_user_t *c)
return c->data;
}
void *
Cache_Check (cache_user_t *c)
{
void *mem;
CACHE_WRITE_LOCK;
mem = Cache_RealCheck (c);
CACHE_WRITE_UNLOCK;
return mem;
}
void *
Cache_Alloc (cache_user_t *c, int size, const char *name)
{

View file

@ -105,7 +105,7 @@ R_RecursiveLightUpdate (mnode_t *node)
surf->cached_dlight = true;
}
static void
static inline void
R_AddDynamicLights_1 (msurface_t *surf)
{
float dist;
@ -170,7 +170,7 @@ R_AddDynamicLights_1 (msurface_t *surf)
}
}
static void
static inline void
R_AddDynamicLights_3 (msurface_t *surf)
{
float dist;

View file

@ -91,7 +91,7 @@ float r_avertexnormal_dots[SHADEDOT_QUANT][256] =
vec3_t shadevector;
static void
static inline void
GL_DrawAliasFrameTri (vert_order_t *vo)
{
float color[4];
@ -116,7 +116,7 @@ GL_DrawAliasFrameTri (vert_order_t *vo)
qfglEnd();
}
static void
static inline void
GL_DrawAliasFrameTri_fb (vert_order_t *vo)
{
int count;
@ -139,7 +139,7 @@ GL_DrawAliasFrameTri_fb (vert_order_t *vo)
qfglEnd();
}
static void
static inline void
GL_DrawAliasFrameTriMulti (vert_order_t *vo)
{
float color[4];
@ -168,7 +168,7 @@ GL_DrawAliasFrameTriMulti (vert_order_t *vo)
qfglEnd ();
}
static void
static inline void
GL_DrawAliasFrame (vert_order_t *vo)
{
float color[4];
@ -208,7 +208,7 @@ GL_DrawAliasFrame (vert_order_t *vo)
}
}
static void
static inline void
GL_DrawAliasFrame_fb (vert_order_t *vo)
{
int count;
@ -243,7 +243,7 @@ GL_DrawAliasFrame_fb (vert_order_t *vo)
}
}
static void
static inline void
GL_DrawAliasFrameMulti (vert_order_t *vo)
{
float color[4];
@ -339,7 +339,7 @@ GL_DrawAliasShadow (aliashdr_t *paliashdr, vert_order_t *vo)
}
}
static vert_order_t *
static inline vert_order_t *
GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e)
{
float interval;
@ -445,7 +445,7 @@ GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e)
return vo;
}
static vert_order_t *
static inline vert_order_t *
GL_GetAliasFrameVerts (int frame, aliashdr_t *paliashdr, entity_t *e)
{
float interval;

View file

@ -144,7 +144,7 @@ R_RenderFullbrights (void)
qfglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
void
inline void
R_RenderBrushPoly (msurface_t *fa)
{
float *v;
@ -233,7 +233,7 @@ R_DrawWaterSurfaces (void)
}
}
static void
static inline void
DrawTextureChains (void)
{
int i;

View file

@ -94,7 +94,7 @@ Skin_Set_Translate (int top, int bottom, void *_dest)
}
}
static void
static inline void
build_skin_8 (byte * original, int tinwidth, int tinheight,
unsigned int scaled_width, unsigned int scaled_height,
int inwidth, qboolean alpha)
@ -121,7 +121,7 @@ build_skin_8 (byte * original, int tinwidth, int tinheight,
alpha);
}
static void
static inline void
build_skin_32 (byte * original, int tinwidth, int tinheight,
unsigned int scaled_width, unsigned int scaled_height,
int inwidth, qboolean alpha)

View file

@ -185,7 +185,7 @@ loc0:
}
}
static void
static inline void
real_mark_surfaces (float dist, msurface_t *surf, const vec3_t lightorigin,
dlight_t *light, int bit)
{