emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp 22da28c 4/6: * Split logic into comp-fwprop-call and


From: Andrea Corallo
Subject: feature/native-comp 22da28c 4/6: * Split logic into comp-fwprop-call and improve it
Date: Sat, 14 Nov 2020 16:07:30 -0500 (EST)

branch: feature/native-comp
commit 22da28cf6643b6293aa0255eca5f398dad23516d
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    * Split logic into comp-fwprop-call and improve it
    
        * lisp/emacs-lisp/comp.el (comp-func-ret-valset)
        (comp-fwprop-call): New functions.
        (comp-fwprop-insn): Remove code duplicaiton and call
        `comp-fwprop-call'.
---
 lisp/emacs-lisp/comp.el | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index fa94d39..ffd4831 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -670,6 +670,11 @@ Return the corresponding `comp-constraint' or 
`comp-constraint-f'."
   (when-let ((spec (gethash func comp-known-constraints-h)))
     (comp-constraint-range (comp-constraint-f-ret spec))))
 
+(defun comp-func-ret-valset (func)
+  "Return the valset returned by function FUNC."
+  (when-let ((spec (gethash func comp-known-constraints-h)))
+    (comp-constraint-valset (comp-constraint-f-ret spec))))
+
 (defun comp-func-unique-in-cu-p (func)
   "Return t if FUNC is known to be unique in the current compilation unit."
   (if (symbolp func)
@@ -2601,26 +2606,29 @@ Return LVAL."
                    (mapcar #'comp-mvar-range rhs-mvars))))
     lval))
 
+(defun comp-fwprop-call (insn lval f args)
+  "Propagate on a call INSN into LVAL.
+F is the function being called with arguments ARGS.
+Fold the call in case."
+  (if-let ((range (comp-func-ret-range f)))
+      (setf (comp-mvar-range lval) range
+            (comp-mvar-typeset lval) nil)
+    (if-let ((valset (comp-func-ret-valset f)))
+        (setf (comp-mvar-valset lval) valset
+              (comp-mvar-typeset lval) nil)
+      (setf (comp-mvar-typeset lval) (comp-func-ret-typeset f))))
+  (comp-function-call-maybe-fold insn f args))
+
 (defun comp-fwprop-insn (insn)
   "Propagate within INSN."
   (pcase insn
     (`(set ,lval ,rval)
      (pcase rval
        (`(,(or 'call 'callref) ,f . ,args)
-        (if-let ((range (comp-func-ret-range f)))
-            (setf (comp-mvar-range lval) range
-                  (comp-mvar-typeset lval) nil)
-          (setf (comp-mvar-typeset lval)
-                (comp-func-ret-typeset f)))
-        (comp-function-call-maybe-fold insn f args))
+        (comp-fwprop-call insn lval f args))
        (`(,(or 'direct-call 'direct-callref) ,f . ,args)
         (let ((f (comp-func-name (gethash f (comp-ctxt-funcs-h comp-ctxt)))))
-          (if-let ((range (comp-func-ret-range f)))
-              (setf (comp-mvar-range lval) range
-                    (comp-mvar-typeset lval) nil)
-            (setf (comp-mvar-typeset lval)
-                  (comp-func-ret-typeset f)))
-          (comp-function-call-maybe-fold insn f args)))
+          (comp-fwprop-call insn lval f args)))
        (_
         (comp-mvar-propagate lval rval))))
     (`(assume ,lval ,rval ,kind)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]