From 7f9fbdaa4e9c02f4f07bf36a472d8f7616c3a219 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 11 Nov 2008 08:38:03 -0600 Subject: [PATCH] cleanup pass didn't properly handle conditionals where both branches were dead --- basis/compiler/tree/cleanup/cleanup-tests.factor | 5 +++++ basis/compiler/tree/cleanup/cleanup.factor | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/basis/compiler/tree/cleanup/cleanup-tests.factor b/basis/compiler/tree/cleanup/cleanup-tests.factor index b77a27800f..13847e55a2 100644 --- a/basis/compiler/tree/cleanup/cleanup-tests.factor +++ b/basis/compiler/tree/cleanup/cleanup-tests.factor @@ -500,3 +500,8 @@ cell-bits 32 = [ [ { array-capacity } declare 1 fixnum+ ] cleaned-up-tree [ { [ #call? ] [ node-input-infos second literal>> 1 = ] } 1&& ] contains? ] unit-test + +[ ] [ + [ { null } declare [ 1 ] [ 2 ] if ] + build-tree normalize propagate cleanup check-nodes +] unit-test diff --git a/basis/compiler/tree/cleanup/cleanup.factor b/basis/compiler/tree/cleanup/cleanup.factor index 4ca058b2e3..becac01cd5 100644 --- a/basis/compiler/tree/cleanup/cleanup.factor +++ b/basis/compiler/tree/cleanup/cleanup.factor @@ -102,7 +102,7 @@ M: #declare cleanup* drop f ; #! If only one branch is live we don't need to branch at #! all; just drop the condition value. dup live-children sift dup length { - { 0 [ 2drop f ] } + { 0 [ drop in-d>> #drop ] } { 1 [ first swap in-d>> #drop prefix ] } [ 2drop ] } case ;