diff --git a/Makefile b/Makefile index 85a583e94b..deaabfa12f 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ ifdef DEBUG DEFAULT_CFLAGS = -g STRIP = touch else - DEFAULT_CFLAGS = -Wall -O3 -fomit-frame-pointer $(SITE_CFLAGS) + DEFAULT_CFLAGS = -Wall -O3 -ffast-math -fomit-frame-pointer $(SITE_CFLAGS) STRIP = strip endif diff --git a/library/compiler/linearizer.factor b/library/compiler/linearizer.factor index d8856d9a39..1cc69f06ba 100644 --- a/library/compiler/linearizer.factor +++ b/library/compiler/linearizer.factor @@ -5,13 +5,19 @@ USING: compiler-backend errors generic lists inference kernel math namespaces prettyprint sequences strings words ; +SYMBOL: simple-labels + GENERIC: linearize* ( node -- ) : linearize ( dataflow -- linear ) #! Transform dataflow IR into linear IR. This strips out #! stack flow information, and flattens conditionals into #! jumps and labels. - [ %prologue , linearize* ] { } make ; + [ + { } clone simple-labels set + %prologue , + linearize* + ] { } make ; : linearize-next node-successor linearize* ; @@ -19,12 +25,26 @@ M: f linearize* ( f -- ) drop ; M: node linearize* ( node -- ) linearize-next ; +: simple-label? ( #label -- ? ) + #! A simple label only contains tail calls to itself. + dup node-param swap node-child [ + dup #call-label? [ + [ node-param = not ] keep node-successor #return? or + ] [ + 2drop t + ] ifte + ] all-nodes-with? ; + +: simple-label ( #label -- ) + dup node-param %label , node-child linearize* ; + M: #label linearize* ( node -- ) -