From eb7eab71a53ddcc9d72b4876c01f2f82bb686b9e Mon Sep 17 00:00:00 2001 From: Paul Khuong Date: Tue, 12 Oct 2010 04:41:16 +0000 Subject: [PATCH] 1.0.43.42: Constant fold IFs before performing IF/IF conversion IF/IF-conversion is somewhat similar to "the trick": when a conditional branches on an lvar that may be written to by multiple nodes, duplicate the conditional after each of the writers. We used to perform that before constant-folding IFs. We now do the reverse: it's always better to completely flush the branch away than to duplicate it. --- src/compiler/ir1opt.lisp | 22 +++++++++++----------- version.lisp-expr | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/compiler/ir1opt.lisp b/src/compiler/ir1opt.lisp index 59b145a..bbcdc89 100644 --- a/src/compiler/ir1opt.lisp +++ b/src/compiler/ir1opt.lisp @@ -635,22 +635,14 @@ ;;;; IF optimization -;;; If the test has multiple uses, replicate the node when possible. -;;; Also check whether the predicate is known to be true or false, +;;; Check whether the predicate is known to be true or false, ;;; deleting the IF node in favor of the appropriate branch when this ;;; is the case. +;;; Also, if the test has multiple uses, replicate the node when possible. (defun ir1-optimize-if (node) (declare (type cif node)) (let ((test (if-test node)) (block (node-block node))) - - (when (and (eq (block-start-node block) node) - (listp (lvar-uses test))) - (do-uses (use test) - (when (immediately-used-p test use) - (convert-if-if use node) - (when (not (listp (lvar-uses test))) (return))))) - (let* ((type (lvar-type test)) (victim (cond ((constant-lvar-p test) @@ -666,7 +658,15 @@ (when (rest (block-succ block)) (unlink-blocks block victim)) (setf (component-reanalyze (node-component node)) t) - (unlink-node node)))) + (unlink-node node) + (return-from ir1-optimize-if (values)))) + + (when (and (eq (block-start-node block) node) + (listp (lvar-uses test))) + (do-uses (use test) + (when (immediately-used-p test use) + (convert-if-if use node) + (when (not (listp (lvar-uses test))) (return)))))) (values)) ;;; Create a new copy of an IF node that tests the value of the node diff --git a/version.lisp-expr b/version.lisp-expr index eb5fa2a..8fe4b2d 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.43.41" +"1.0.43.42" -- 1.7.10.4