compiler.cfg.two-operand: sometimes we can eliminate a copy in the x = y <op> y case

db4
Slava Pestov 2009-08-08 20:03:42 -05:00
parent 55acddef3f
commit 24a50c8006
2 changed files with 19 additions and 2 deletions

View File

@ -35,3 +35,18 @@ compiler.cfg.registers cpu.architecture namespaces tools.test ;
T{ ##sub-float f 1 2 3 }
} (convert-two-operand)
] unit-test
[
V{
T{ ##copy f 1 2 double-float-rep }
T{ ##mul-float f 1 1 1 }
}
] [
H{
{ 1 double-float-rep }
{ 2 double-float-rep }
} clone representations set
{
T{ ##mul-float f 1 2 2 }
} (convert-two-operand)
] unit-test

View File

@ -48,8 +48,10 @@ GENERIC: convert-two-operand* ( insn -- )
M: two-operand-insn convert-two-operand*
[ [ dst>> ] [ src1>> ] bi emit-copy ]
[ dup dst>> >>src1 , ]
bi ;
[
dup [ src1>> ] [ src2>> ] bi = [ dup dst>> >>src2 ] when
dup dst>> >>src1 ,
] bi ;
M: ##not convert-two-operand*
[ [ dst>> ] [ src>> ] bi emit-copy ]