[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp 3b3525b 5/6: Backward propagate only once
From: |
Andrea Corallo |
Subject: |
feature/native-comp 3b3525b 5/6: Backward propagate only once |
Date: |
Sat, 15 Feb 2020 04:24:38 -0500 (EST) |
branch: feature/native-comp
commit 3b3525b916eee975697e9c3c72a5fd780f6eecd6
Author: AndreaCorallo <address@hidden>
Commit: Andrea Corallo <address@hidden>
Backward propagate only once
---
lisp/emacs-lisp/comp.el | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 701cba3..6476603 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -99,9 +99,9 @@ Can be used by code that wants to expand differently in this
case.")
(defconst comp-passes '(comp-spill-lap
comp-limplify
comp-ssa
- comp-propagate
+ comp-propagate-1
comp-call-optim
- comp-propagate
+ comp-propagate-2
comp-dead-code
comp-final)
"Passes to be executed in order.")
@@ -1571,11 +1571,10 @@ PRE-LAMBDA and POST-LAMBDA are called in pre or
post-order if non nil."
(copy-comp-mvar insn)
insn)))
+
(defun comp-ref-args-to-array (args)
"Given ARGS assign them to a dedicated array."
- (when (and args
- ;; Never rename an already renamed array index.
- (= (comp-mvar-array-idx (car args)) 0))
+ (when args
(cl-loop with array-h = (comp-func-array-h comp-func)
with arr-idx = (hash-table-count array-h)
for i from 0
@@ -1583,26 +1582,32 @@ PRE-LAMBDA and POST-LAMBDA are called in pre or
post-order if non nil."
initially
(puthash arr-idx (length args) array-h)
do
- ;; Just check that all args have zeroed arr-idx.
- ;; (arrays must be used once).
+ ;; We are not supposed to rename arrays more then once.
+ ;; This because we do only one final back propagation
+ ;; and arrays are used only once.
+
+ ;; Note: this last is just a property of the code generated
+ ;; by the byte-compiler.
(cl-assert (= (comp-mvar-array-idx arg) 0))
(setf (comp-mvar-slot arg) i)
(setf (comp-mvar-array-idx arg) arr-idx))))
-(defun comp-propagate-once ()
+(defun comp-propagate-prologue (backward)
"Prologue for the propagate pass.
Here goes everything that can be done not iteratively (read once).
-- Forward propagate immediate involed in assignments
-- Backward propagate placement into arrays"
+- Forward propagate immediate involed in assignments.
+- Backward propagate array layout when BACKWARD is non nil."
(cl-loop
for b being each hash-value of (comp-func-blocks comp-func)
do (cl-loop
for insn in (comp-block-insns b)
do (pcase insn
(`(set ,_lval (,(or 'callref 'direct-callref) ,_f . ,args))
- (comp-ref-args-to-array args))
+ (when backward
+ (comp-ref-args-to-array args)))
(`(,(or 'callref 'direct-callref) ,_f . ,args)
- (comp-ref-args-to-array args))
+ (when backward
+ (comp-ref-args-to-array args)))
(`(setimm ,lval ,_ ,v)
(setf (comp-mvar-const-vld lval) t
(comp-mvar-constant lval) v
@@ -1695,13 +1700,13 @@ Return t if something was changed."
do (setf modified t))
finally return modified))
-(defun comp-propagate (_)
+(defun comp-propagate-iterate (backward)
(when (>= comp-speed 2)
(maphash (lambda (_ f)
;; FIXME remove the following condition when tested.
(unless (comp-func-has-non-local f)
(let ((comp-func f))
- (comp-propagate-once)
+ (comp-propagate-prologue backward)
(cl-loop
for i from 1
while (comp-propagate*)
@@ -1709,6 +1714,15 @@ Return t if something was changed."
(comp-log-func comp-func 3))))
(comp-ctxt-funcs-h comp-ctxt))))
+(defun comp-propagate-1 (_)
+ "Forward propagate types and consts within the lattice."
+ (comp-propagate-iterate nil))
+
+(defun comp-propagate-2 (_)
+ "Forward propagate types and consts within the lattice.
+Backward propagate array placement properties."
+ (comp-propagate-iterate t))
+
;;; Call optimizer pass specific code.
;; This pass is responsible for the following optimizations:
- feature/native-comp updated (d71801e -> 4b4c753), Andrea Corallo, 2020/02/15
- feature/native-comp 0c6f4ca 3/6: Clean-up old gc disable refuse in comp-tests-non-locals, Andrea Corallo, 2020/02/15
- feature/native-comp fe9e4c4 2/6: Better function naming for comp-function-call-maybe-remove, Andrea Corallo, 2020/02/15
- feature/native-comp 3b3525b 5/6: Backward propagate only once,
Andrea Corallo <=
- feature/native-comp 4b4c753 6/6: Speed 2 goes default, Andrea Corallo, 2020/02/15
- feature/native-comp c27394d 4/6: Rework frame layout, Andrea Corallo, 2020/02/15
- feature/native-comp f1bc8e4 1/6: Merge remote-tracking branch 'savannah/master' into HEAD, Andrea Corallo, 2020/02/15