0.6.11.10:
[sbcl.git] / src / compiler / typetran.lisp
1 ;;;; This file contains stuff that implements the portable IR1
2 ;;;; semantics of type tests and coercion. The main thing we do is
3 ;;;; convert complex type operations into simpler code that can be
4 ;;;; compiled inline.
5
6 ;;;; This software is part of the SBCL system. See the README file for
7 ;;;; more information.
8 ;;;;
9 ;;;; This software is derived from the CMU CL system, which was
10 ;;;; written at Carnegie Mellon University and released into the
11 ;;;; public domain. The software is in the public domain and is
12 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
13 ;;;; files for more information.
14
15 (in-package "SB!C")
16 \f
17 ;;;; type predicate translation
18 ;;;;
19 ;;;; We maintain a bidirectional association between type predicates
20 ;;;; and the tested type. The presence of a predicate in this
21 ;;;; association implies that it is desirable to implement tests of
22 ;;;; this type using the predicate. These are either predicates that
23 ;;;; the back end is likely to have special knowledge about, or
24 ;;;; predicates so complex that the only reasonable implentation is
25 ;;;; via function call.
26 ;;;;
27 ;;;; Some standard types (such as SEQUENCE) are best tested by letting
28 ;;;; the TYPEP source transform do its thing with the expansion. These
29 ;;;; types (and corresponding predicates) are not maintained in this
30 ;;;; association. In this case, there need not be any predicate
31 ;;;; function unless it is required by the Common Lisp specification.
32 ;;;;
33 ;;;; The mapping between predicates and type structures is considered
34 ;;;; part of the backend; different backends can support different
35 ;;;; sets of predicates.
36
37 (defmacro define-type-predicate (name type)
38   #!+sb-doc
39   "Define-Type-Predicate Name Type
40   Establish an association between the type predicate Name and the
41   corresponding Type. This causes the type predicate to be recognized for
42   purposes of optimization."
43   `(%define-type-predicate ',name ',type))
44 (defun %define-type-predicate (name specifier)
45   (let ((type (specifier-type specifier)))
46     (setf (gethash name *backend-predicate-types*) type)
47     (setf *backend-type-predicates*
48           (cons (cons type name)
49                 (remove name *backend-type-predicates*
50                         :key #'cdr)))
51     (%deftransform name '(function (t) *) #'fold-type-predicate)
52     name))
53 \f
54 ;;;; IR1 transforms
55
56 ;;; If we discover the type argument is constant during IR1
57 ;;; optimization, then give the source transform another chance. The
58 ;;; source transform can't pass, since we give it an explicit
59 ;;; constant. At worst, it will convert to %TYPEP, which will prevent
60 ;;; spurious attempts at transformation (and possible repeated
61 ;;; warnings.)
62 (deftransform typep ((object type))
63   (unless (constant-continuation-p type)
64     (give-up-ir1-transform "can't open-code test of non-constant type"))
65   `(typep object ',(continuation-value type)))
66
67 ;;; If the continuation OBJECT definitely is or isn't of the specified
68 ;;; type, then return T or NIL as appropriate. Otherwise quietly
69 ;;; GIVE-UP-IR1-TRANSFORM.
70 (defun ir1-transform-type-predicate (object type)
71   (declare (type continuation object) (type ctype type))
72   (let ((otype (continuation-type object)))
73     (cond ((not (types-intersect otype type))
74            'nil)
75           ((csubtypep otype type)
76            't)
77           (t
78            (give-up-ir1-transform)))))
79
80 ;;; Flush %TYPEP tests whose result is known at compile time.
81 (deftransform %typep ((object type))
82   (unless (constant-continuation-p type) (give-up-ir1-transform))
83   (ir1-transform-type-predicate
84    object
85    (specifier-type (continuation-value type))))
86
87 ;;; This is the IR1 transform for simple type predicates. It checks
88 ;;; whether the single argument is known to (not) be of the
89 ;;; appropriate type, expanding to T or NIL as appropriate.
90 (deftransform fold-type-predicate ((object) * * :node node :defun-only t)
91   (let ((ctype (gethash (leaf-name
92                          (ref-leaf
93                           (continuation-use
94                            (basic-combination-fun node))))
95                         *backend-predicate-types*)))
96     (assert ctype)
97     (ir1-transform-type-predicate object ctype)))
98
99 ;;; If FIND-CLASS is called on a constant class, locate the CLASS-CELL
100 ;;; at load time.
101 (deftransform find-class ((name) ((constant-argument symbol)) *
102                           :when :both)
103   (let* ((name (continuation-value name))
104          (cell (find-class-cell name)))
105     `(or (class-cell-class ',cell)
106          (error "class not yet defined: ~S" name))))
107 \f
108 ;;;; standard type predicates
109
110 ;;; FIXME: needed only at cold load time, can be uninterned afterwards;
111 ;;; or perhaps could just be done at toplevel
112 (defun define-standard-type-predicates ()
113   (define-type-predicate arrayp array)
114   ; (The ATOM predicate is handled separately as (NOT CONS).)
115   (define-type-predicate bit-vector-p bit-vector)
116   (define-type-predicate characterp character)
117   (define-type-predicate compiled-function-p compiled-function)
118   (define-type-predicate complexp complex)
119   (define-type-predicate complex-rational-p (complex rational))
120   (define-type-predicate complex-float-p (complex float))
121   (define-type-predicate consp cons)
122   (define-type-predicate floatp float)
123   (define-type-predicate functionp function)
124   (define-type-predicate integerp integer)
125   (define-type-predicate keywordp keyword)
126   (define-type-predicate listp list)
127   (define-type-predicate null null)
128   (define-type-predicate numberp number)
129   (define-type-predicate rationalp rational)
130   (define-type-predicate realp real)
131   (define-type-predicate simple-bit-vector-p simple-bit-vector)
132   (define-type-predicate simple-string-p simple-string)
133   (define-type-predicate simple-vector-p simple-vector)
134   (define-type-predicate stringp string)
135   (define-type-predicate %instancep instance)
136   (define-type-predicate funcallable-instance-p funcallable-instance)
137   (define-type-predicate symbolp symbol)
138   (define-type-predicate vectorp vector))
139
140 (define-standard-type-predicates)
141 \f
142 ;;;; transforms for type predicates not implemented primitively
143 ;;;;
144 ;;;; See also VM dependent transforms.
145
146 (def-source-transform atom (x)
147   `(not (consp ,x)))
148 \f
149 ;;;; TYPEP source transform
150
151 ;;; Return a form that tests the variable N-OBJECT for being in the
152 ;;; binds specified by TYPE. BASE is the name of the base type, for
153 ;;; declaration. We make SAFETY locally 0 to inhibit any checking of
154 ;;; this assertion.
155 #!-negative-zero-is-not-zero
156 (defun transform-numeric-bound-test (n-object type base)
157   (declare (type numeric-type type))
158   (let ((low (numeric-type-low type))
159         (high (numeric-type-high type)))
160     `(locally
161        (declare (optimize (safety 0)))
162        (and ,@(when low
163                 (if (consp low)
164                     `((> (the ,base ,n-object) ,(car low)))
165                     `((>= (the ,base ,n-object) ,low))))
166             ,@(when high
167                 (if (consp high)
168                     `((< (the ,base ,n-object) ,(car high)))
169                     `((<= (the ,base ,n-object) ,high))))))))
170
171 #!+negative-zero-is-not-zero
172 (defun transform-numeric-bound-test (n-object type base)
173   (declare (type numeric-type type))
174   (let ((low (numeric-type-low type))
175         (high (numeric-type-high type))
176         (float-type-p (csubtypep type (specifier-type 'float)))
177         (x (gensym))
178         (y (gensym)))
179     `(locally
180        (declare (optimize (safety 0)))
181        (and ,@(when low
182                 (if (consp low)
183                     `((let ((,x (the ,base ,n-object))
184                             (,y ,(car low)))
185                         ,(if (not float-type-p)
186                             `(> ,x ,y)
187                             `(if (and (zerop ,x) (zerop ,y))
188                                  (> (float-sign ,x) (float-sign ,y))
189                                  (> ,x ,y)))))
190                     `((let ((,x (the ,base ,n-object))
191                             (,y ,low))
192                         ,(if (not float-type-p)
193                             `(>= ,x ,y)
194                             `(if (and (zerop ,x) (zerop ,y))
195                                  (>= (float-sign ,x) (float-sign ,y))
196                                  (>= ,x ,y)))))))
197             ,@(when high
198                 (if (consp high)
199                     `((let ((,x (the ,base ,n-object))
200                             (,y ,(car high)))
201                         ,(if (not float-type-p)
202                              `(< ,x ,y)
203                              `(if (and (zerop ,x) (zerop ,y))
204                                   (< (float-sign ,x) (float-sign ,y))
205                                   (< ,x ,y)))))
206                     `((let ((,x (the ,base ,n-object))
207                             (,y ,high))
208                         ,(if (not float-type-p)
209                              `(<= ,x ,y)
210                              `(if (and (zerop ,x) (zerop ,y))
211                                   (<= (float-sign ,x) (float-sign ,y))
212                                   (<= ,x ,y)))))))))))
213
214 ;;; Do source transformation of a test of a known numeric type. We can
215 ;;; assume that the type doesn't have a corresponding predicate, since
216 ;;; those types have already been picked off. In particular, CLASS
217 ;;; must be specified, since it is unspecified only in NUMBER and
218 ;;; COMPLEX. Similarly, we assume that COMPLEXP is always specified.
219 ;;;
220 ;;; For non-complex types, we just test that the number belongs to the
221 ;;; base type, and then test that it is in bounds. When CLASS is
222 ;;; INTEGER, we check to see whether the range is no bigger than
223 ;;; FIXNUM. If so, we check for FIXNUM instead of INTEGER. This allows
224 ;;; us to use fixnum comparison to test the bounds.
225 ;;;
226 ;;; For complex types, we must test for complex, then do the above on
227 ;;; both the real and imaginary parts. When CLASS is float, we need
228 ;;; only check the type of the realpart, since the format of the
229 ;;; realpart and the imagpart must be the same.
230 (defun source-transform-numeric-typep (object type)
231   (let* ((class (numeric-type-class type))
232          (base (ecase class
233                  (integer (containing-integer-type type))
234                  (rational 'rational)
235                  (float (or (numeric-type-format type) 'float))
236                  ((nil) 'real))))
237     (once-only ((n-object object))
238       (ecase (numeric-type-complexp type)
239         (:real
240          `(and (typep ,n-object ',base)
241                ,(transform-numeric-bound-test n-object type base)))
242         (:complex
243          `(and (complexp ,n-object)
244                ,(once-only ((n-real `(realpart (the complex ,n-object)))
245                             (n-imag `(imagpart (the complex ,n-object))))
246                   `(progn
247                      ,n-imag ; ignorable
248                      (and (typep ,n-real ',base)
249                           ,@(when (eq class 'integer)
250                               `((typep ,n-imag ',base)))
251                           ,(transform-numeric-bound-test n-real type base)
252                           ,(transform-numeric-bound-test n-imag type
253                                                          base))))))))))
254
255 ;;; Do the source transformation for a test of a hairy type. AND,
256 ;;; SATISFIES and NOT are converted into the obvious code. We convert
257 ;;; unknown types to %TYPEP, emitting an efficiency note if
258 ;;; appropriate.
259 (defun source-transform-hairy-typep (object type)
260   (declare (type hairy-type type))
261   (let ((spec (hairy-type-specifier type)))
262     (cond ((unknown-type-p type)
263            (when (policy nil (> speed inhibit-warnings))
264              (compiler-note "can't open-code test of unknown type ~S"
265                             (type-specifier type)))
266            `(%typep ,object ',spec))
267           (t
268            (ecase (first spec)
269              (satisfies `(if (funcall #',(second spec) ,object) t nil))
270              ((not and)
271               (once-only ((n-obj object))
272                 `(,(first spec) ,@(mapcar #'(lambda (x)
273                                               `(typep ,n-obj ',x))
274                                           (rest spec))))))))))
275
276 ;;; Do source transformation for TYPEP of a known union type. If a
277 ;;; union type contains LIST, then we pull that out and make it into a
278 ;;; single LISTP call. Note that if SYMBOL is in the union, then LIST
279 ;;; will be a subtype even without there being any (member NIL). We
280 ;;; just drop through to the general code in this case, rather than
281 ;;; trying to optimize it.
282 (defun source-transform-union-typep (object type)
283   (let* ((types (union-type-types type))
284          (ltype (specifier-type 'list))
285          (mtype (find-if #'member-type-p types)))
286     (cond ((and mtype (csubtypep ltype type))
287            (let ((members (member-type-members mtype)))
288              (once-only ((n-obj object))
289                `(if (listp ,n-obj)
290                     t
291                     (typep ,n-obj
292                            '(or ,@(mapcar #'type-specifier
293                                           (remove (specifier-type 'cons)
294                                                   (remove mtype types)))
295                                 (member ,@(remove nil members))))))))
296           (t
297            (once-only ((n-obj object))
298              `(or ,@(mapcar #'(lambda (x)
299                                 `(typep ,n-obj ',(type-specifier x)))
300                             types)))))))
301
302 ;;; Do source transformation for TYPEP of a known intersection type.
303 (defun source-transform-intersection-typep (object type)
304   ;; FIXME: This is just a placeholder; we should define a better
305   ;; version by analogy with SOURCE-TRANSFORM-UNION-TYPEP.
306   (declare (ignore object type))
307   nil)
308
309 ;;; If necessary recurse to check the cons type.
310 (defun source-transform-cons-typep (object type)
311   (let* ((car-type (cons-type-car-type type))
312          (cdr-type (cons-type-cdr-type type)))
313     (let ((car-test-p (not (or (type= car-type *wild-type*)
314                                (type= car-type (specifier-type t)))))
315           (cdr-test-p (not (or (type= cdr-type *wild-type*)
316                                (type= cdr-type (specifier-type t))))))
317       (if (and (not car-test-p) (not cdr-test-p))
318           `(consp ,object)
319           (once-only ((n-obj object))
320             `(and (consp ,n-obj)
321                   ,@(if car-test-p
322                         `((typep (car ,n-obj)
323                                  ',(type-specifier car-type))))
324                   ,@(if cdr-test-p
325                         `((typep (cdr ,n-obj)
326                                  ',(type-specifier cdr-type))))))))))
327  
328 ;;; Return the predicate and type from the most specific entry in
329 ;;; *TYPE-PREDICATES* that is a supertype of TYPE.
330 (defun find-supertype-predicate (type)
331   (declare (type ctype type))
332   (let ((res nil)
333         (res-type nil))
334     (dolist (x *backend-type-predicates*)
335       (let ((stype (car x)))
336         (when (and (csubtypep type stype)
337                    (or (not res-type)
338                        (csubtypep stype res-type)))
339           (setq res-type stype)
340           (setq res (cdr x)))))
341     (values res res-type)))
342
343 ;;; Return forms to test that OBJ has the rank and dimensions
344 ;;; specified by TYPE, where STYPE is the type we have checked against
345 ;;; (which is the same but for dimensions.)
346 (defun test-array-dimensions (obj type stype)
347   (declare (type array-type type stype))
348   (let ((obj `(truly-the ,(type-specifier stype) ,obj))
349         (dims (array-type-dimensions type)))
350     (unless (eq dims '*)
351       (collect ((res))
352         (when (eq (array-type-dimensions stype) '*)
353           (res `(= (array-rank ,obj) ,(length dims))))
354         (do ((i 0 (1+ i))
355              (dim dims (cdr dim)))
356             ((null dim))
357           (let ((dim (car dim)))
358             (unless (eq dim '*)
359               (res `(= (array-dimension ,obj ,i) ,dim)))))
360         (res)))))
361
362 ;;; If we can find a type predicate that tests for the type w/o
363 ;;; dimensions, then use that predicate and test for dimensions.
364 ;;; Otherwise, just do %TYPEP.
365 (defun source-transform-array-typep (obj type)
366   (multiple-value-bind (pred stype) (find-supertype-predicate type)
367     (if (and (array-type-p stype)
368              ;; (If the element type hasn't been defined yet, it's
369              ;; not safe to assume here that it will eventually
370              ;; have (UPGRADED-ARRAY-ELEMENT-TYPE type)=T, so punt.)
371              (not (unknown-type-p (array-type-element-type type)))
372              (type= (array-type-specialized-element-type stype)
373                     (array-type-specialized-element-type type))
374              (eq (array-type-complexp stype) (array-type-complexp type)))
375         (once-only ((n-obj obj))
376           `(and (,pred ,n-obj)
377                 ,@(test-array-dimensions n-obj type stype)))
378         `(%typep ,obj ',(type-specifier type)))))
379
380 ;;; Transform a type test against some instance type. The type test is
381 ;;; flushed if the result is known at compile time. If not properly
382 ;;; named, error. If sealed and has no subclasses, just test for
383 ;;; layout-EQ. If a structure then test for layout-EQ and then a
384 ;;; general test based on layout-inherits. If safety is important,
385 ;;; then we also check whether the layout for the object is invalid
386 ;;; and signal an error if so. Otherwise, look up the indirect
387 ;;; class-cell and call CLASS-CELL-TYPEP at runtime.
388 ;;;
389 ;;; KLUDGE: The :WHEN :BOTH option here is probably a suboptimal
390 ;;; solution to the problem of %INSTANCE-TYPEP forms in byte compiled
391 ;;; code; it'd probably be better just to have %INSTANCE-TYPEP forms
392 ;;; never be generated in byte compiled code, or maybe to have a DEFUN
393 ;;; %INSTANCE-TYPEP somewhere to handle them if they are. But it's not
394 ;;; terribly important because mostly, %INSTANCE-TYPEP forms *aren't*
395 ;;; generated in byte compiled code. (As of sbcl-0.6.5, they could
396 ;;; sometimes be generated when byte compiling inline functions, but
397 ;;; it's quite uncommon.) -- WHN 20000523
398 (deftransform %instance-typep ((object spec) * * :when :both)
399   (assert (constant-continuation-p spec))
400   (let* ((spec (continuation-value spec))
401          (class (specifier-type spec))
402          (name (sb!xc:class-name class))
403          (otype (continuation-type object))
404          (layout (let ((res (info :type :compiler-layout name)))
405                    (if (and res (not (layout-invalid res)))
406                        res
407                        nil))))
408     (/noshow "entering DEFTRANSFORM %INSTANCE-TYPEP" otype spec class name layout)
409     (cond
410       ;; Flush tests whose result is known at compile time.
411       ((not (types-intersect otype class))
412        (/noshow "flushing constant NIL")
413        nil)
414       ((csubtypep otype class)
415        (/noshow "flushing constant T")
416        t)
417       ;; If not properly named, error.
418       ((not (and name (eq (sb!xc:find-class name) class)))
419        (compiler-error "can't compile TYPEP of anonymous or undefined ~
420                         class:~%  ~S"
421                        class))
422       (t
423        ;; Otherwise transform the type test.
424        (multiple-value-bind (pred get-layout)
425            (cond
426              ((csubtypep class (specifier-type 'funcallable-instance))
427               (values 'funcallable-instance-p '%funcallable-instance-layout))
428              ((csubtypep class (specifier-type 'instance))
429               (values '%instancep '%instance-layout))
430              (t
431               (values '(lambda (x) (declare (ignore x)) t) 'layout-of)))
432          (/noshow pred get-layout)
433          (cond
434            ((and (eq (class-state class) :sealed) layout
435                  (not (class-subclasses class)))
436             ;; Sealed and has no subclasses.
437             (/noshow "sealed and has no subclasses")
438             (let ((n-layout (gensym)))
439               `(and (,pred object)
440                     (let ((,n-layout (,get-layout object)))
441                       ,@(when (policy nil (>= safety speed))
442                               `((when (layout-invalid ,n-layout)
443                                   (%layout-invalid-error object ',layout))))
444                       (eq ,n-layout ',layout)))))
445            ((and (typep class 'basic-structure-class) layout)
446             (/noshow "structure type tests; hierarchical layout depths")
447             ;; structure type tests; hierarchical layout depths
448             (let ((depthoid (layout-depthoid layout))
449                   (n-layout (gensym)))
450               `(and (,pred object)
451                     (let ((,n-layout (,get-layout object)))
452                       ,@(when (policy nil (>= safety speed))
453                               `((when (layout-invalid ,n-layout)
454                                   (%layout-invalid-error object ',layout))))
455                       (if (eq ,n-layout ',layout)
456                           t
457                           (and (> (layout-depthoid ,n-layout)
458                                   ,depthoid)
459                                (locally (declare (optimize (safety 0)))
460                                  (eq (svref (layout-inherits ,n-layout)
461                                             ,depthoid)
462                                      ',layout))))))))
463            (t
464             (/noshow "default case -- ,PRED and CLASS-CELL-TYPEP")
465             `(and (,pred object)
466                   (class-cell-typep (,get-layout object)
467                                     ',(find-class-cell name)
468                                     object)))))))))
469
470 ;;; If the specifier argument is a quoted constant, then we consider
471 ;;; converting into a simple predicate or other stuff. If the type is
472 ;;; constant, but we can't transform the call, then we convert to
473 ;;; %TYPEP. We only pass when the type is non-constant. This allows us
474 ;;; to recognize between calls that might later be transformed
475 ;;; successfully when a constant type is discovered. We don't give an
476 ;;; efficiency note when we pass, since the IR1 transform will give
477 ;;; one if necessary and appropriate.
478 ;;;
479 ;;; If the type is TYPE= to a type that has a predicate, then expand
480 ;;; to that predicate. Otherwise, we dispatch off of the type's type.
481 ;;; These transformations can increase space, but it is hard to tell
482 ;;; when, so we ignore policy and always do them. When byte-compiling,
483 ;;; we only do transforms that have potential for control
484 ;;; simplification. Instance type tests are converted to
485 ;;; %INSTANCE-TYPEP to allow type propagation.
486 (def-source-transform typep (object spec)
487   (if (and (consp spec) (eq (car spec) 'quote))
488       (let ((type (specifier-type (cadr spec))))
489         (or (let ((pred (cdr (assoc type *backend-type-predicates*
490                                     :test #'type=))))
491               (when pred `(,pred ,object)))
492             (typecase type
493               (hairy-type
494                (source-transform-hairy-typep object type))
495               (union-type
496                (source-transform-union-typep object type))
497               (intersection-type
498                (source-transform-intersection-typep object type))
499               (member-type
500                `(member ,object ',(member-type-members type)))
501               (args-type
502                (compiler-warning "illegal type specifier for TYPEP: ~S"
503                                  (cadr spec))
504                `(%typep ,object ,spec))
505               (t nil))
506             (and (not (byte-compiling))
507                  (typecase type
508                    (numeric-type
509                     (source-transform-numeric-typep object type))
510                    (sb!xc:class
511                     `(%instance-typep ,object ,spec))
512                    (array-type
513                     (source-transform-array-typep object type))
514                    (cons-type
515                     (source-transform-cons-typep object type))
516                    (t nil)))
517             `(%typep ,object ,spec)))
518       (values nil t)))
519 \f
520 ;;;; coercion
521
522 ;;; old working version
523 (deftransform coerce ((x type) (* *) * :when :both)
524   (unless (constant-continuation-p type)
525     (give-up-ir1-transform))
526   (let ((tspec (specifier-type (continuation-value type))))
527     (if (csubtypep (continuation-type x) tspec)
528         'x
529         `(the ,(continuation-value type)
530               ,(cond ((csubtypep tspec (specifier-type 'double-float))
531                       '(%double-float x))       
532                      ;; FIXME: If LONG-FLOAT is to be supported, we
533                      ;; need to pick it off here before falling through
534                      ;; to %SINGLE-FLOAT.
535                      ((csubtypep tspec (specifier-type 'float))
536                       '(%single-float x))
537                      (t
538                       (give-up-ir1-transform)))))))
539
540 ;;; KLUDGE: new broken version -- 20000504
541 ;;; FIXME: should be fixed or deleted
542 #+nil
543 (deftransform coerce ((x type) (* *) * :when :both)
544   (unless (constant-continuation-p type)
545     (give-up-ir1-transform))
546   (let ((tspec (specifier-type (continuation-value type))))
547     (if (csubtypep (continuation-type x) tspec)
548         'x
549         `(if #+nil (typep x type) #-nil nil
550              x
551              (the ,(continuation-value type)
552                   ,(cond ((csubtypep tspec (specifier-type 'double-float))
553                           '(%double-float x))   
554                          ;; FIXME: If LONG-FLOAT is to be supported,
555                          ;; we need to pick it off here before falling
556                          ;; through to %SINGLE-FLOAT.
557                          ((csubtypep tspec (specifier-type 'float))
558                           '(%single-float x))
559                          #+nil
560                          ((csubtypep tspec (specifier-type 'list))
561                           '(coerce-to-list x))
562                          #+nil
563                          ((csubtypep tspec (specifier-type 'string))
564                           '(coerce-to-simple-string x))
565                          #+nil
566                          ((csubtypep tspec (specifier-type 'bit-vector))
567                           '(coerce-to-bit-vector x))
568                          #+nil
569                          ((csubtypep tspec (specifier-type 'vector))
570                           '(coerce-to-vector x type))
571                          (t
572                           (give-up-ir1-transform))))))))