inline fixnum multiplication

svn: r12731
This commit is contained in:
Matthew Flatt 2008-12-08 13:36:24 +00:00
parent 104fa42d97
commit 4d8469b6cf
5 changed files with 23 additions and 13 deletions

View File

@ -253,6 +253,10 @@
(bin -12 '* -3 4)
(bin -12 '* 3 -4)
(bin 12 '* -3 -4)
(bin (expt 2 70) '* 2 (expt 2 69))
(bin (expt 2 30) '* 2 (expt 2 29))
(bin (expt 2 31) '* 2 (expt 2 30))
(bin (- (expt 2 30)) '* 2 (- (expt 2 29)))
(bin 0 '/ 0 4)
(bin 1/4 '/ 1 4)

View File

@ -3185,10 +3185,7 @@ static int generate_arith(mz_jit_state *jitter, Scheme_Object *rator, Scheme_Obj
}
CHECK_LIMIT();
if (arith == 2) {
if (rand2 || ((v != 0) && (v != 1)))
has_fixnum_fast = 0;
} else if (arith == -2) {
if (arith == -2) {
if (rand2 || (v != 1) || reversed)
has_fixnum_fast = 0;
}
@ -3326,10 +3323,10 @@ static int generate_arith(mz_jit_state *jitter, Scheme_Object *rator, Scheme_Obj
}
jit_ori_ul(JIT_R0, JIT_R2, 0x1);
} else if (arith == 2) {
if (has_fixnum_fast) {
/* No fast path for fixnum multiplication, yet */
(void)jit_jmpi(refslow);
}
jit_andi_ul(JIT_R2, JIT_R1, (~0x1));
jit_rshi_l(JIT_V1, JIT_R0, 0x1);
(void)jit_bomulr_l(refslow, JIT_V1, JIT_R2);
jit_ori_ul(JIT_R0, JIT_V1, 0x1);
} else if (arith == -2) {
if (has_fixnum_fast) {
/* No fast path for fixnum division, yet */
@ -3432,11 +3429,11 @@ static int generate_arith(mz_jit_state *jitter, Scheme_Object *rator, Scheme_Obj
} else if (v == 0) {
(void)jit_movi_p(JIT_R0, scheme_make_integer(0));
} else {
if (has_fixnum_fast) {
/* No general fast path for fixnum multiplication, yet */
(void)jit_movi_p(JIT_R1, scheme_make_integer(v));
(void)jit_jmpi(refslow);
}
(void)jit_movi_p(JIT_R1, scheme_make_integer(v));
jit_andi_ul(JIT_R2, JIT_R1, (~0x1));
jit_rshi_l(JIT_V1, JIT_R0, 0x1);
(void)jit_bomulr_l(refslow, JIT_V1, JIT_R2);
jit_ori_ul(JIT_R0, JIT_V1, 0x1);
}
} else if (arith == -2) {
if ((v == 1) && !reversed) {

View File

@ -217,6 +217,11 @@ typedef _uc jit_insn;
# define _qOr( OP,R ) _Or(OP,R)
#endif
#define _OO( OP ) ( _jit_B((OP)>>8), _jit_B( (OP) ) )
#ifdef JIT_X86_64
# define _qOO(OP) ( _REX(0,0,0), _OO(OP))
#else
# define _qOO(OP) _OO(OP)
#endif
#define _OOr( OP,R ) ( _jit_B((OP)>>8), _jit_B( (OP)|_r(R)) )
#define _Os( OP,B ) ( _s8P(B) ? _jit_B(((OP)|_b10)) : _jit_B(OP) )
#ifdef JIT_X86_64
@ -240,6 +245,7 @@ typedef _uc jit_insn;
#define _O_Mrm( OP ,MO,R,M ) ( _O ( OP ),_Mrm(MO,R,M ) )
#define _qO_Mrm( OP ,MO,R,M ) ( _qO ( OP,R,0,M),_qMrm(MO,R,M ) )
#define _OO_Mrm( OP ,MO,R,M ) ( _OO ( OP ),_Mrm(MO,R,M ) )
#define _qOO_Mrm( OP ,MO,R,M ) ( _qOO ( OP ),_Mrm(MO,R,M ) )
#define _O_Mrm_B( OP ,MO,R,M ,B ) ( _O ( OP ),_Mrm(MO,R,M ) ,_jit_B(B) )
#define _qO_Mrm_B( OP ,MO,R,M ,B ) ( _qO ( OP,R,0,M),_qMrm(MO,R,M ) ,_jit_B(B) )
#define _O_Mrm_W( OP ,MO,R,M ,W ) ( _O ( OP ),_Mrm(MO,R,M ) ,_jit_W(W) )
@ -500,6 +506,7 @@ typedef _uc jit_insn;
#define IMULLirr(IM,RS,RD) _Os_Mrm_sL (0x69 ,_b11,_r4(RS),_r4(RD) ,IM )
#define IMULLimr(IM,MD,MB,MI,MS,RD) _Os_r_X_sL (0x69 ,_r4(RD) ,MD,MB,MI,MS ,IM )
#define IMULQrr(RS,RD) _qOO_Mrm (0x0faf ,_b11,_r4(RD),_r4(RS) )
#define INCBr(RD) _O_Mrm (0xfe ,_b11,_b000 ,_r1(RD) )
#define INCBm(MD,MB,MI,MS) _O_r_X (0xfe ,_b000 ,MD,MB,MI,MS )

View File

@ -467,6 +467,7 @@ static int jit_arg_reg_order[] = { _EDI, _ESI, _EDX, _ECX };
#define jit_bosubr_l(label, s1, s2) (SUBQrr((s2), (s1)), JOm(label,0,0,0), _jit.x.pc)
#define jit_boaddr_ul(label, s1, s2) (ADDQrr((s2), (s1)), JCm(label,0,0,0), _jit.x.pc)
#define jit_bosubr_ul(label, s1, s2) (SUBQrr((s2), (s1)), JCm(label,0,0,0), _jit.x.pc)
#define jit_bomulr_l(label, s1, s2) (IMULQrr((s2), (s1)), JOm(label,0,0,0), _jit.x.pc)
#define jit_blti_i(label, rs, is) jit_bra_i0((rs), (is), JLm(label, 0,0,0), JSm(label, 0,0,0) )
#define jit_blei_i(label, rs, is) jit_bra_i ((rs), (is), JLEm(label,0,0,0) )

View File

@ -177,6 +177,7 @@ struct jit_local_state {
#define jit_bosubi_ui(label, rs, is) (jit_chk_ims ((is), SUBICri((rs), (rs), is), SUBCrr((rs), JIT_AUX)), MCRXRi(0), BEQi((label)), _jit.x.pc)
#define jit_boaddr_ui(label, s1, s2) ( ADDCrr((s1), (s1), (s2)), MCRXRi(0), BEQi((label)), _jit.x.pc)
#define jit_bosubr_ui(label, s1, s2) ( SUBCrr((s1), (s1), (s2)), MCRXRi(0), BEQi((label)), _jit.x.pc)
#define jit_bomulr_i(label, s1, s2) ( MULLWOrrr((s1), (s1), (s2)), MCRXRi(0), BGTi((label)), _jit.x.pc)
#define jit_calli(label) ((void)jit_movi_p(JIT_AUX, (label)), MTCTRr(JIT_AUX), BCTRL(), _jitl.nextarg_puti = _jitl.nextarg_putf = _jitl.nextarg_putd = 0, _jit.x.pc)
#define jit_callr(reg) (MTCTRr(reg), BCTRL())
#define jit_divi_i(d, rs, is) jit_big_ims((is), DIVWrrr ((d), (rs), JIT_AUX))