compiler.cfg.value-numbering: add slot addressing rewrite rule to eliminate a redundant ##add-imm from array-nth and set-array-nth
parent
2475699736
commit
b8d556514c
|
@ -0,0 +1 @@
|
|||
Slava Pestov
|
|
@ -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 ;
|
|
@ -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{
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue