From 79d337cb08f74244e5ed1bdad09ea7e768ea273d Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 18 Oct 2005 13:19:11 +0000 Subject: * generic/tclExecute.c: Added optimization for I32L64 systems to avoid using bignums to perform int multiplies. The improvement shows up most dramatically in tclbench's matrix.bench. --- ChangeLog | 6 ++++++ generic/tclExecute.c | 24 ++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71f6396..3618f4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-10-18 Don Porter + + * generic/tclExecute.c: Added optimization for I32L64 systems to + avoid using bignums to perform int multiplies. The improvement + shows up most dramatically in tclbench's matrix.bench. + 2005-10-15 Don Porter * generic/tclExecute.c: Restored some optimizations of the diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 126f8d8..6663dfd 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclExecute.c,v 1.214 2005/10/15 23:27:18 dgp Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.215 2005/10/18 13:19:12 dgp Exp $ */ #include "tclInt.h" @@ -4498,7 +4498,27 @@ TclExecuteByteCode(interp, codePtr) NEXT_INST_F(1, 1, 0); } - if ((*pc == INST_MULT) && (sizeof(Tcl_WideInt) >= 2*sizeof(long)) + if ((sizeof(long) >= 2*sizeof(int)) && (*pc == INST_MULT) + && (type1 == TCL_NUMBER_LONG) && (type2 == TCL_NUMBER_LONG)) { + long l1 = *((CONST long *)ptr1); + long l2 = *((CONST long *)ptr2); + if ((l1 <= INT_MAX) && (l1 >= INT_MIN) + && (l2 <= INT_MAX) && (l2 >= INT_MIN)) { + long lResult = l1 * l2; + + TRACE(("%s %s => ", O2S(valuePtr), O2S(value2Ptr))); + if (Tcl_IsShared(valuePtr)) { + TclNewLongObj(objResultPtr,lResult); + TRACE(("%s\n", O2S(objResultPtr))); + NEXT_INST_F(1, 2, 1); + } + TclSetLongObj(valuePtr, lResult); + TRACE(("%s\n", O2S(valuePtr))); + NEXT_INST_F(1, 1, 0); + } + } + + if ((sizeof(Tcl_WideInt) >= 2*sizeof(long)) && (*pc == INST_MULT) && (type1 == TCL_NUMBER_LONG) && (type2 == TCL_NUMBER_LONG)) { Tcl_WideInt w1, w2, wResult; TclGetWideIntFromObj(NULL, valuePtr, &w1); -- cgit v0.12