diff --git a/basis/compiler/cfg/linearization/linearization.factor b/basis/compiler/cfg/linearization/linearization.factor index f9e0e54afc..cc148d34d8 100755 --- a/basis/compiler/cfg/linearization/linearization.factor +++ b/basis/compiler/cfg/linearization/linearization.factor @@ -26,8 +26,7 @@ M: insn linearize-insn , drop ; [ number>> ] bi@ 1 - = ; inline : emit-loop-entry? ( bb successor -- ? ) - [ back-edge? not ] - [ nip dup predecessors>> [ swap back-edge? ] with any? ] 2bi and ; + [ back-edge? not ] [ nip loop-entry? ] 2bi and ; : emit-branch ( bb successor -- ) 2dup emit-loop-entry? [ _loop-entry ] when diff --git a/basis/compiler/cfg/utilities/utilities.factor b/basis/compiler/cfg/utilities/utilities.factor index 8cb70cc649..d242d5d90d 100644 --- a/basis/compiler/cfg/utilities/utilities.factor +++ b/basis/compiler/cfg/utilities/utilities.factor @@ -15,6 +15,9 @@ PREDICATE: kill-block < basic-block : back-edge? ( from to -- ? ) [ number>> ] bi@ >= ; +: loop-entry? ( bb -- ? ) + dup predecessors>> [ swap back-edge? ] with any? ; + : empty-block? ( bb -- ? ) instructions>> { [ length 1 = ]