emacs-diffs
[Top][All Lists]
Advanced

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

feature/native-comp 54f2e9c 2/2: * Improve `comp-fwprop-call'


From: Andrea Corallo
Subject: feature/native-comp 54f2e9c 2/2: * Improve `comp-fwprop-call'
Date: Sun, 15 Nov 2020 15:17:58 -0500 (EST)

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

    * Improve `comp-fwprop-call'
    
        * lisp/emacs-lisp/comp.el (comp-function-call-maybe-fold):
        Document return value.
        (comp-fwprop-call): Simplify and improve.
---
 lisp/emacs-lisp/comp.el | 33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)

diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index b8f19b5..397b0fd 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -723,22 +723,6 @@ Return the corresponding `comp-constraint' or 
`comp-constraint-f'."
   "Type-hint predicate for function name FUNC."
   (when (memq func comp-type-hints) t))
 
-(defun comp-func-ret-typeset (func)
-  "Return the typeset returned by function FUNC."
-  (if-let ((spec (gethash func comp-known-constraints-h)))
-      (comp-constraint-typeset (comp-constraint-f-ret spec))
-    '(t)))
-
-(defun comp-func-ret-range (func)
-  "Return the range returned by function FUNC."
-  (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)
@@ -2604,7 +2588,8 @@ Forward propagate immediate involed in assignments."
        (cl-every #'comp-mvar-value-vld-p args)))
 
 (defun comp-function-call-maybe-fold (insn f args)
-  "Given INSN when F is pure if all ARGS are known remove the function call."
+  "Given INSN when F is pure if all ARGS are known remove the function call.
+Return non-nil if the function is folded successfully."
   (cl-flet ((rewrite-insn-as-setimm (insn value)
                ;; See `comp-emit-setimm'.
                (comp-add-const-to-relocs value)
@@ -2675,14 +2660,12 @@ Return LVAL."
   "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))
+  (unless (comp-function-call-maybe-fold insn f args)
+    (when-let ((constr (gethash f comp-known-constraints-h)))
+      (let ((constr (comp-constraint-f-ret constr)))
+        (setf (comp-mvar-range lval) (comp-constraint-range constr)
+              (comp-mvar-valset lval) (comp-constraint-valset constr)
+              (comp-mvar-typeset lval) (comp-constraint-typeset constr))))))
 
 (defun comp-fwprop-insn (insn)
   "Propagate within INSN."



reply via email to

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