Revert "Optimize vswap()"
This reverts commit 63193d1794
.
Had some problems (_STATIC_ASSERT) and was too ugly anyway.
For retry, I'd suggest to implement a general function
static inline void memswap (void *p1, void* p2, size_t n);
and then use that. If you do so, please keep the original code
as comment.
This commit is contained in:
parent
2daf8b96a8
commit
c5892fe4f5
2 changed files with 8 additions and 33 deletions
4
tcc.h
4
tcc.h
|
@ -228,10 +228,6 @@
|
||||||
#define true 1
|
#define true 1
|
||||||
typedef int BOOL;
|
typedef int BOOL;
|
||||||
|
|
||||||
#ifndef _STATIC_ASSERT
|
|
||||||
#define _STATIC_ASSERT(cond) do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define INCLUDE_STACK_SIZE 32
|
#define INCLUDE_STACK_SIZE 32
|
||||||
#define IFDEF_STACK_SIZE 64
|
#define IFDEF_STACK_SIZE 64
|
||||||
#define VSTACK_SIZE 256
|
#define VSTACK_SIZE 256
|
||||||
|
|
37
tccgen.c
37
tccgen.c
|
@ -458,7 +458,7 @@ static void vseti(int r, int v)
|
||||||
|
|
||||||
ST_FUNC void vswap(void)
|
ST_FUNC void vswap(void)
|
||||||
{
|
{
|
||||||
unsigned long *vtopl;
|
SValue tmp;
|
||||||
/* cannot let cpu flags if other instruction are generated. Also
|
/* cannot let cpu flags if other instruction are generated. Also
|
||||||
avoid leaving VT_JMP anywhere except on the top of the stack
|
avoid leaving VT_JMP anywhere except on the top of the stack
|
||||||
because it would complicate the code generator. */
|
because it would complicate the code generator. */
|
||||||
|
@ -467,35 +467,14 @@ ST_FUNC void vswap(void)
|
||||||
if (v == VT_CMP || (v & ~1) == VT_JMP)
|
if (v == VT_CMP || (v & ~1) == VT_JMP)
|
||||||
gv(RC_INT);
|
gv(RC_INT);
|
||||||
}
|
}
|
||||||
|
tmp = vtop[0];
|
||||||
|
vtop[0] = vtop[-1];
|
||||||
|
vtop[-1] = tmp;
|
||||||
|
|
||||||
/*
|
/* XXX: +2% overall speed possible with optimized memswap
|
||||||
* vtop[0], vtop[-1] = vtop[-1], vtop[0]
|
*
|
||||||
*
|
* memswap(&vtop[0], &vtop[1], sizeof *vtop);
|
||||||
* vswap is called often and exchanging vtop[0] vs vtop[-1] is hot on
|
*/
|
||||||
* profile, so it is hand optimized
|
|
||||||
*/
|
|
||||||
vtopl = (unsigned long *) vtop;
|
|
||||||
# define VSIZEL (sizeof(*vtop) / sizeof(*vtopl))
|
|
||||||
|
|
||||||
_STATIC_ASSERT( VSIZEL*sizeof(*vtopl) == sizeof(*vtop) );
|
|
||||||
_STATIC_ASSERT( VSIZEL <= 16 ); /* should be enough */
|
|
||||||
switch(VSIZEL) {
|
|
||||||
# define VSWAPL(i) \
|
|
||||||
case i+1: { \
|
|
||||||
unsigned long tmpl; \
|
|
||||||
tmpl = vtopl[i]; \
|
|
||||||
vtopl[i] = vtopl[-1*VSIZEL + i]; \
|
|
||||||
vtopl[-1*VSIZEL + i] = tmpl; \
|
|
||||||
} do {} while (0)
|
|
||||||
|
|
||||||
VSWAPL(15); VSWAPL(14); VSWAPL(13); VSWAPL(12);
|
|
||||||
VSWAPL(11); VSWAPL(10); VSWAPL( 9); VSWAPL( 8);
|
|
||||||
VSWAPL( 7); VSWAPL( 6); VSWAPL( 5); VSWAPL( 4);
|
|
||||||
VSWAPL( 3); VSWAPL( 2); VSWAPL( 1); VSWAPL( 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
# undef VSWAPL
|
|
||||||
# undef VSIZEL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ST_FUNC void vpushv(SValue *v)
|
ST_FUNC void vpushv(SValue *v)
|
||||||
|
|
Loading…
Reference in a new issue