Somewhat clunky optimization for reusing temporary variable slots
This commit is contained in:
parent
3f470688a4
commit
f8f5892d98
1 changed files with 19 additions and 1 deletions
|
@ -58,4 +58,22 @@
|
||||||
:test-not #'eql :key #'strategy)))
|
:test-not #'eql :key #'strategy)))
|
||||||
(loop :for allocation :in (append named temporary)
|
(loop :for allocation :in (append named temporary)
|
||||||
:do (setf (varvec-index allocation) (incf counter))))
|
:do (setf (varvec-index allocation) (incf counter))))
|
||||||
allocations))
|
(remove-if #'null allocations :key (lambda (a) (users (data a))))))
|
||||||
|
|
||||||
|
(defun optim-reuse-temporary-slots (start-iblock allocations)
|
||||||
|
(let ((free '()))
|
||||||
|
(do-iblocks (iblock start-iblock)
|
||||||
|
(do-instructions (inst iblock)
|
||||||
|
(let ((ending (find inst allocations
|
||||||
|
:key (alexandria:compose #'last-use
|
||||||
|
#'data)))
|
||||||
|
(beginning (find (output inst) allocations :key #'data)))
|
||||||
|
(cond ((and ending
|
||||||
|
(eql (strategy ending) :temporary-variable)
|
||||||
|
(not (null (varvec-index ending))))
|
||||||
|
(pushnew (varvec-index ending) free))
|
||||||
|
((and beginning
|
||||||
|
(eql (strategy beginning) :temporary-variable)
|
||||||
|
(not (null (varvec-index beginning)))
|
||||||
|
(not (null free)))
|
||||||
|
(setf (varvec-index beginning) (pop free)))))))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue