compiler.cfg.value-numbering: add slot addressing rewrite rule to eliminate a redundant ##add-imm from array-nth and set-array-nth

db4
Slava Pestov 2010-04-23 20:52:59 -04:00
parent 2475699736
commit b8d556514c
4 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,25 @@
! Copyright (C) 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators.short-circuit cpu.architecture fry
kernel math
compiler.cfg.instructions
compiler.cfg.value-numbering.graph
compiler.cfg.value-numbering.rewrite
compiler.cfg.value-numbering.expressions ;
IN: compiler.cfg.value-numbering.slots
: simplify-slot-addressing? ( insn -- ? )
complex-addressing?
[ slot>> vreg>expr add-imm-expr? ] [ drop f ] if ;
: simplify-slot-addressing ( insn -- insn/f )
dup simplify-slot-addressing? [
dup slot>> vreg>expr
[ src1>> vn>vreg >>slot ]
[ src2>> vn>integer over scale>> '[ _ _ shift - ] change-tag ]
bi
] [ drop f ] if ;
M: ##slot rewrite simplify-slot-addressing ;
M: ##set-slot rewrite simplify-slot-addressing ;
M: ##write-barrier rewrite simplify-slot-addressing ;

View File

@ -2209,6 +2209,25 @@ V{
[ f ] [ 1 get instructions>> [ ##peek? ] any? ] unit-test
! Slot addressing optimization
cpu x86? [
[
V{
T{ ##peek f 0 D 0 }
T{ ##peek f 1 D 1 }
T{ ##add-imm f 2 1 2 }
T{ ##slot f 3 0 1 2 $[ 7 2 cells - ] }
}
] [
V{
T{ ##peek f 0 D 0 }
T{ ##peek f 1 D 1 }
T{ ##add-imm f 2 1 2 }
T{ ##slot f 3 0 2 2 7 }
} value-numbering-step
] unit-test
] when
! Alien addressing optimization
[
V{

View File

@ -14,7 +14,8 @@ compiler.cfg.value-numbering.expressions
compiler.cfg.value-numbering.graph
compiler.cfg.value-numbering.math
compiler.cfg.value-numbering.rewrite
compiler.cfg.value-numbering.simplify ;
compiler.cfg.value-numbering.simplify
compiler.cfg.value-numbering.slots ;
IN: compiler.cfg.value-numbering
! Local value numbering.