[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp 0b81044 02/14: * Clean-up some const folding logic a
From: |
Andrea Corallo |
Subject: |
feature/native-comp 0b81044 02/14: * Clean-up some const folding logic and add `comp-function-pure-p' |
Date: |
Thu, 9 Jul 2020 11:57:51 -0400 (EDT) |
branch: feature/native-comp
commit 0b81044e7e7500fcee3f984c1abeaa544118c5ee
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
* Clean-up some const folding logic and add `comp-function-pure-p'
* lisp/emacs-lisp/comp.el (comp-function-pure-p): New predicate.
(comp-function-call-maybe-remove): Update to use the
`comp-function-pure-p'.
---
lisp/emacs-lisp/comp.el | 35 +++++++++++------------------------
1 file changed, 11 insertions(+), 24 deletions(-)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index da567fd..ef9dc5b 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -443,6 +443,15 @@ structure.")
finally return t)
t))
+(defsubst comp-function-pure-p (f)
+ "Return t if F is pure."
+ (or (get f 'pure)
+ (when-let ((func (gethash (gethash f
+ (comp-ctxt-sym-to-c-name-h
+ comp-ctxt))
+ (comp-ctxt-funcs-h comp-ctxt))))
+ (comp-func-pure func))))
+
(defsubst comp-alloc-class-to-container (alloc-class)
"Given ALLOC-CLASS return the data container for the current context.
Assume allocaiton class 'd-default as default."
@@ -1899,17 +1908,6 @@ PRE-LAMBDA and POST-LAMBDA are called in pre or
post-order if non nil."
;; This is also responsible for removing function calls to pure functions if
;; possible.
-(defvar comp-propagate-classes '(byte-optimize-associative-math
- byte-optimize-binary-predicate
- byte-optimize-concat
- byte-optimize-equal
- byte-optimize-identity
- byte-optimize-member
- byte-optimize-memq
- byte-optimize-predicate)
- "We optimize functions with 'byte-optimizer' property set to
- one of these symbols. See byte-opt.el.")
-
(defsubst comp-strict-type-of (obj)
"Given OBJ return its type understanding fixnums."
;; Should be certainly smarter but now we take advantages just from fixnums.
@@ -1981,21 +1979,10 @@ Here goes everything that can be done not iteratively
(read once).
(comp-mvar-constant lval) (comp-mvar-constant rval)
(comp-mvar-type lval) (comp-mvar-type rval)))
-;; Here should fall most of (defun byte-optimize-* equivalents.
(defsubst comp-function-optimizable-p (f args)
"Given function F called with ARGS return non nil when optimizable."
- (when (cl-every #'comp-mvar-const-vld args)
- (or (when-let ((func (gethash (gethash f
- (comp-ctxt-sym-to-c-name-h
- comp-ctxt))
- (comp-ctxt-funcs-h comp-ctxt))))
- (comp-func-pure func))
- (get f 'pure)
- (memq (get f 'byte-optimizer) comp-propagate-classes)
- (let ((values (mapcar #'comp-mvar-constant args)))
- (pcase f
- ((or '+ '- '* '1+ '-1) t)
- ('/ (not (= (car (last values)) 0))))))))
+ (and (cl-every #'comp-mvar-const-vld args)
+ (comp-function-pure-p f)))
(defsubst comp-function-call-maybe-remove (insn f args)
"Given INSN when F is pure if all ARGS are known remove the function call."
- feature/native-comp updated (2593bbe -> 5f13016), Andrea Corallo, 2020/07/09
- feature/native-comp 0b81044 02/14: * Clean-up some const folding logic and add `comp-function-pure-p',
Andrea Corallo <=
- feature/native-comp b31b0eb 03/14: * Rework some test logic for generality, Andrea Corallo, 2020/07/09
- feature/native-comp 3d43d45 01/14: Merge remote-tracking branch 'savannah/master' into HEAD, Andrea Corallo, 2020/07/09
- feature/native-comp 4348969 06/14: * test/src/comp-test-funcs.el (comp-tests-aref-aset-f) : Fix UB., Andrea Corallo, 2020/07/09
- feature/native-comp 5688739 07/14: * Add `comp-call-op-p', Andrea Corallo, 2020/07/09
- feature/native-comp 9aaca82 12/14: * Add `comp-disabled-passes', Andrea Corallo, 2020/07/09
- feature/native-comp e6ab4e3 04/14: * Add a test targeting forward propagation, Andrea Corallo, 2020/07/09
- feature/native-comp 3db6ace 05/14: * Define `comp-symbol-func-to-fun', Andrea Corallo, 2020/07/09
- feature/native-comp 7622740 08/14: * Introduce a new pass ipa-pure, Andrea Corallo, 2020/07/09
- feature/native-comp b4de6ba 09/14: * Optimize pure functions defined by the compilation environment, Andrea Corallo, 2020/07/09
- feature/native-comp 5f13016 14/14: Merge remote-tracking branch 'savannah/master' into wip2, Andrea Corallo, 2020/07/09