Fix cleanup of conditionals with no live branches
parent
c9df16e931
commit
783d0fcabf
|
@ -102,8 +102,11 @@ M: #declare cleanup* drop f ;
|
||||||
: fold-only-branch ( #branch -- node/nodes )
|
: fold-only-branch ( #branch -- node/nodes )
|
||||||
#! If only one branch is live we don't need to branch at
|
#! If only one branch is live we don't need to branch at
|
||||||
#! all; just drop the condition value.
|
#! all; just drop the condition value.
|
||||||
dup live-children sift dup length 1 =
|
dup live-children sift dup length {
|
||||||
[ first swap in-d>> #drop prefix ] [ drop ] if ;
|
{ 0 [ 2drop f ] }
|
||||||
|
{ 1 [ first swap in-d>> #drop prefix ] }
|
||||||
|
[ 2drop ]
|
||||||
|
} case ;
|
||||||
|
|
||||||
SYMBOL: live-branches
|
SYMBOL: live-branches
|
||||||
|
|
||||||
|
@ -118,15 +121,18 @@ M: #branch cleanup*
|
||||||
[ live-branches>> live-branches set ]
|
[ live-branches>> live-branches set ]
|
||||||
} cleave ;
|
} cleave ;
|
||||||
|
|
||||||
|
: output-fs ( values -- nodes )
|
||||||
|
[ f swap #push ] map ;
|
||||||
|
|
||||||
: eliminate-single-phi ( #phi -- node )
|
: eliminate-single-phi ( #phi -- node )
|
||||||
[ phi-in-d>> first ] [ out-d>> ] bi over [ +bottom+ eq? ] all?
|
[ phi-in-d>> first ] [ out-d>> ] bi over [ +bottom+ eq? ] all?
|
||||||
[ [ drop ] [ [ f swap #push ] map ] bi* ]
|
[ [ drop ] [ output-fs ] bi* ]
|
||||||
[ #copy ]
|
[ #copy ]
|
||||||
if ;
|
if ;
|
||||||
|
|
||||||
: eliminate-phi ( #phi -- node )
|
: eliminate-phi ( #phi -- node )
|
||||||
live-branches get sift length {
|
live-branches get sift length {
|
||||||
{ 0 [ drop f ] }
|
{ 0 [ out-d>> output-fs ] }
|
||||||
{ 1 [ eliminate-single-phi ] }
|
{ 1 [ eliminate-single-phi ] }
|
||||||
[ drop ]
|
[ drop ]
|
||||||
} case ;
|
} case ;
|
||||||
|
|
Loading…
Reference in New Issue