From 47c73b316a434da5bab4e39b746bbe9a0f17aa8c Mon Sep 17 00:00:00 2001 From: Lutz Euler Date: Mon, 6 May 2013 19:37:23 +0200 Subject: [PATCH] Make CONTAINING-INTEGER-TYPE take N-WORD-BITS into account. Replace the hardcoded 32s in the function with N-WORD-BITS. This in turn allows SOURCE-TRANSFORM-NUMERIC-TYPEP to find better transformations for type checks for types larger than fixnum but smaller than a machine word also under 64-bit word size. The most important improvement this achieves is to avoid generic arithmetic for the bounds tests in these cases. For example, the test (TYPEP X '(UNSIGNED-BYTE 63)) runs about four times as fast on x86-64 with this change. (Tests for the exact types (SIGNED-BYTE 64) and (UNSIGNED-BYTE 64) are unaffected as compiling them takes another code path, which already generates well optimized code.) --- NEWS | 4 ++++ src/compiler/generic/vm-type.lisp | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 411d233..48e6e1f 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,10 @@ changes relative to sbcl-1.1.7: * optimization: faster and smaller INTEGER-LENGTH on fixnums on x86-64. * optimization: On x86-64, the number of multi-byte NOP instructions used for code alignment is now always minimal. + * optimization: On 64-bit targets, the compiler generates much faster + code for type checks for types known at compile time that are smaller + than (SIGNED-BYTE 64) or (UNSIGNED-BYTE 64) and larger than FIXNUM, and + their COMPLEX variants. changes in sbcl-1.1.7 relative to sbcl-1.1.6: * enhancement: TRACE :PRINT-ALL handles multiple-valued forms. diff --git a/src/compiler/generic/vm-type.lisp b/src/compiler/generic/vm-type.lisp index 618de2b..ccacc48 100644 --- a/src/compiler/generic/vm-type.lisp +++ b/src/compiler/generic/vm-type.lisp @@ -172,9 +172,9 @@ ;;; Return the most specific integer type that can be quickly checked that ;;; includes the given type. (defun containing-integer-type (subtype) - (dolist (type '(fixnum - (signed-byte 32) - (unsigned-byte 32) + (dolist (type `(fixnum + (signed-byte ,sb!vm:n-word-bits) + (unsigned-byte ,sb!vm:n-word-bits) integer) (error "~S isn't an integer type?" subtype)) (when (csubtypep subtype (specifier-type type)) -- 1.7.10.4