diff options
author | dgp <dgp@users.sourceforge.net> | 2005-10-18 13:19:11 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2005-10-18 13:19:11 (GMT) |
commit | 79d337cb08f74244e5ed1bdad09ea7e768ea273d (patch) | |
tree | 05fff8877cba4a1902cf04760eaacc672d76ea33 | |
parent | a604518cad44246120133ea4fe4192c6442e3d44 (diff) | |
download | tcl-79d337cb08f74244e5ed1bdad09ea7e768ea273d.zip tcl-79d337cb08f74244e5ed1bdad09ea7e768ea273d.tar.gz tcl-79d337cb08f74244e5ed1bdad09ea7e768ea273d.tar.bz2 |
* 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.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclExecute.c | 24 |
2 files changed, 28 insertions, 2 deletions
@@ -1,3 +1,9 @@ +2005-10-18 Don Porter <dgp@users.sourceforge.net> + + * 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 <dgp@users.sourceforge.net> * 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); |