]> git.eshelyaron.com Git - emacs.git/commitdiff
fix comp-propagate-insn type propagation
authorAndrea Corallo <akrl@sdf.org>
Mon, 25 Nov 2019 20:27:11 +0000 (21:27 +0100)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:38:11 +0000 (11:38 +0100)
lisp/emacs-lisp/comp.el

index 4167dcf4b9128b20cfe0d6303d34eb6f35d52f61..2ac912929d1c2901df6790730ae0303fd9264a84 100644 (file)
@@ -1553,14 +1553,19 @@ This can run just once."
         (comp-mvar-propagate lval rval))))
     (`(phi ,lval . ,rest)
      ;; Const prop here.
-     (when (and (cl-every #'comp-mvar-const-vld rest)
-                (cl-reduce #'equal (mapcar #'comp-mvar-constant rest)))
-       (setf (comp-mvar-constant lval) (comp-mvar-constant (car rest))))
+     (when-let* ((vld (cl-every #'comp-mvar-const-vld rest))
+                 (consts (mapcar #'comp-mvar-constant rest))
+                 (x (car consts))
+                 (equals (cl-every (lambda (y) (equal x y)) consts)))
+       (setf (comp-mvar-constant lval) x))
      ;; Type propagation.
      ;; FIXME: checking for type equality is not sufficient cause does not
-     ;; account type hierarchy!!
-     (when (cl-reduce #'eq (mapcar #'comp-mvar-type rest))
-       (setf (comp-mvar-type lval) (comp-mvar-type (car rest))))
+     ;; account type hierarchy!
+     (when-let* ((types (mapcar #'comp-mvar-type rest))
+                 (non-empty (cl-notany #'null types))
+                 (x (car types))
+                 (eqs (cl-every (lambda (y) (eq x y)) types)))
+       (setf (comp-mvar-type lval) x))
      ;; Reference propagation.
      (let ((operands (cons lval rest)))
        (when (cl-some #'comp-mvar-ref operands)