Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize empty IR components #285

Open
davazp opened this issue Jun 21, 2018 · 0 comments
Open

Optimize empty IR components #285

davazp opened this issue Jun 21, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@davazp
Copy link
Member

davazp commented Jun 21, 2018

Consider this word from test-case.fs:

: test-case ( n -- )
  case
    1 of 10 endof
    2 of 20 endof
    3 of 30 endof
    100 swap
  endcase ;

The IR generated by the compiler (see below) includes some empty components. Components that consist of a single IR_NODE_CONTINUE node.

Those empty components make the code generator generate some jp, to jump between the components. This could be avoided if we implement a coalesce-ir-components optimization to remove those IR components.

========== test-case ( $10AB16F80 ) ========== 

[ $7FCD10602050 ]
LITERAL $1 
CALL over  ( $10AB0C848 )
CALL =  ( $10AB0E9A0 )
0<>IF $7FCD10602160 ELSE $7FCD10602180 

[ $7FCD10602180 ]
LITERAL $2 
CALL over  ( $10AB0C848 )
CALL =  ( $10AB0E9A0 )
0<>IF $7FCD106023F0 ELSE $7FCD10602410 

[ $7FCD10602410 ]
LITERAL $3 
CALL over  ( $10AB0C848 )
CALL =  ( $10AB0E9A0 )
0<>IF $7FCD10602680 ELSE $7FCD106026A0 

[ $7FCD106026A0 ]
LITERAL $64 
CALL swap  ( $10AB0C6E8 )
CALL drop  ( $10AB0C650 )
CONTINUE $7FCD106027B0 

[ $7FCD10602680 ]
CALL drop  ( $10AB0C650 )
LITERAL $1E 
CONTINUE $7FCD106027B0 

[ $7FCD106027B0 ]
CONTINUE $7FCD10602520 

[ $7FCD106023F0 ]
CALL drop  ( $10AB0C650 )
LITERAL $14 
CONTINUE $7FCD10602520 

[ $7FCD10602520 ]
CONTINUE $7FCD10602290 

[ $7FCD10602160 ]
CALL drop  ( $10AB0C650 )
LITERAL $A 
CONTINUE $7FCD10602290 

[ $7FCD10602290 ]
RET
@davazp davazp added enhancement New feature or request xcompiler labels Jun 21, 2018
@tkers tkers removed the xcompiler label Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants