Even safer substitution of constants in CUT-TO-WIDTH
authorPaul Khuong <pvk@pvk.ca>
Fri, 24 May 2013 17:13:12 +0000 (13:13 -0400)
committerPaul Khuong <pvk@pvk.ca>
Fri, 24 May 2013 18:49:41 +0000 (14:49 -0400)
 * Fix another aspect of the modular arithmetic bug that was only
   partially fixed by ccd2a1d (Substitute constants with modular
   equivalents more safely); detected by the previous fix not
   working on !x86oids.

src/compiler/ir1opt.lisp
src/compiler/ir1util.lisp
src/compiler/srctran.lisp

index 838f284..7f44b64 100644 (file)
 ;;; What we do is intersect RTYPE with NODE's DERIVED-TYPE. If the
 ;;; intersection is different from the old type, then we do a
 ;;; REOPTIMIZE-LVAR on the NODE-LVAR.
-(defun derive-node-type (node rtype)
+(defun derive-node-type (node rtype &key from-scratch)
   (declare (type valued-node node) (type ctype rtype))
-  (let ((node-type (node-derived-type node)))
-    (unless (eq node-type rtype)
+  (let* ((initial-type (node-derived-type node))
+         (node-type (if from-scratch
+                        *wild-type*
+                        initial-type)))
+    (unless (eq initial-type rtype)
       (let ((int (values-type-intersection node-type rtype))
             (lvar (node-lvar node)))
-        (when (type/= node-type int)
+        (when (type/= initial-type int)
           (when (and *check-consistency*
                      (eq int *empty-type*)
                      (not (eq rtype *empty-type*)))
+            (aver (not from-scratch))
             (let ((*compiler-error-context* node))
               (compiler-warn
                "New inferred type ~S conflicts with old type:~
index dc96f0c..7d9f2f3 100644 (file)
@@ -1894,7 +1894,7 @@ is :ANY, the function name is not checked."
 ;;;; leaf hackery
 
 ;;; Change the LEAF that a REF refers to.
-(defun change-ref-leaf (ref leaf)
+(defun change-ref-leaf (ref leaf &key recklessly)
   (declare (type ref ref) (type leaf leaf))
   (unless (eq (ref-leaf ref) leaf)
     (push ref (leaf-refs leaf))
@@ -1909,7 +1909,7 @@ is :ANY, the function name is not checked."
                  (eq lvar (basic-combination-fun dest))
                  (csubtypep ltype (specifier-type 'function))))
           (setf (node-derived-type ref) vltype)
-          (derive-node-type ref vltype)))
+          (derive-node-type ref vltype :from-scratch recklessly)))
     (reoptimize-lvar (node-lvar ref)))
   (values))
 
index caed9bf..4fc7754 100644 (file)
                                            (mask-signed-field width constant-value)
                                            (ldb (byte width 0) constant-value))))
                        (unless (= constant-value new-value)
-                         (change-ref-leaf node (make-constant new-value))
+                         (change-ref-leaf node (make-constant new-value)
+                                          :recklessly t)
                          (let ((lvar (node-lvar node)))
                            (setf (lvar-%derived-type lvar)
                                  (and (lvar-has-single-use-p lvar)