##add
] { } make ;
+! XXX the vregs that src>> vreg>insn uses are not necessarily available
: rewrite-unbox-any-c-ptr ( insn -- insn/f )
dup src>> vreg>insn
{
: fuse-base-offset? ( insn -- ? )
base>> vreg>insn ##add-imm? ;
+! XXX base>> vreg>insn src1>> not necessarily available
: fuse-base-offset ( insn -- insn' )
clone dup base>> vreg>insn
[ src1>> ] [ src2>> ] bi
: fuse-displacement-offset? ( insn -- ? )
{ [ scale>> 0 = ] [ displacement>> vreg>insn ##add-imm? ] } 1&& ;
+! XXX displacement>> vreg>insn src1>> not necessarily available
: fuse-displacement-offset ( insn -- insn' )
clone dup displacement>> vreg>insn
[ src1>> ] [ src2>> ] bi
M: ##load-memory-imm new-alien-insn drop \ ##load-memory new-insn ;
M: ##store-memory-imm new-alien-insn drop \ ##store-memory new-insn ;
+! XXX base>> vreg>insn src1>> & src2>> not necessarily
+! available
: fuse-displacement ( insn -- insn' )
{
[ alien-insn-value ]
: fuse-scale? ( insn -- ? )
{ [ scale>> 0 = ] [ displacement>> vreg>insn scale-insn? ] } 1&& ;
+! XXX displacement>> vreg>insn src1>> not necessarily available
: fuse-scale ( insn -- insn' )
clone dup displacement>> vreg>insn
[ src1>> ] [ src2>> ] bi
[ cc>> { cc= cc/= } member? ]
} 1&& ; inline
+! XXX the vregs that src1>> vreg>insn uses are not necessarily available
: rewrite-redundant-comparison ( insn -- insn' )
[ cc>> ] [ dst>> ] [ src1>> vreg>insn ] tri {
{ [ dup ##compare? ] [ >compare< next-vreg \ ##compare new-insn ] }
[ drop f ]
} cond ;
+! XXX the vregs (src1>> and src2>>) that src1>> vreg>insn uses
+! are not necessarily available
: (simplify-test) ( insn -- src1 src2 cc )
[ src1>> vreg>insn [ src1>> ] [ src2>> ] bi ] [ cc>> ] bi ; inline
: simplify-test-branch ( insn -- insn )
(simplify-test) \ ##test-branch new-insn ; inline
+! XXX the vregs (src1>> and src2>>) that src1>> vreg>insn uses
+! are not necessarily available
: (simplify-test-imm) ( insn -- src1 src2 cc )
[ src1>> vreg>insn [ src1>> ] [ src2>> ] bi ] [ cc>> ] bi ; inline
[ 2drop f ]
} cond ;
+! XXX src>> vreg>insn src>> not necessarily available
: self-inverse ( insn -- insn' )
[ dst>> ] [ src>> vreg>insn src>> ] bi <copy> ;
: mul-to-shl ( insn -- insn' )
[ [ dst>> ] [ src1>> ] bi ] [ src2>> log2 ] bi \ ##shl-imm new-insn ;
+! XXX not sure if availability is an issue
! Distribution converts
! ##+-imm 2 1 X
! ##*-imm 3 2 Y
[ swap \ ##replace-imm new-insn ] [ 2drop f ] if
] [ 2drop f ] if ;
+! XXX any particular input's vn isn't necessarily available, so
+! can't just return a straight-up <copy>; might just do
+! this with a set-vn in gvn.factor:value-number
M: ##phi rewrite
[ dst>> ] [ inputs>> values [ vreg>vn ] map sift ] bi
dup all-equal? [
! Some lame constant folding for SIMD intrinsics. Eventually this
! should be redone completely.
+! XXX pretty much all of these rely on the vregs used by some
+! vreg>insn, but they aren't necessarily available
+
: useless-shuffle-vector-imm? ( insn -- ? )
[ shuffle>> ] [ rep>> rep-length iota ] bi sequence= ;
complex-addressing?
[ slot>> vreg>insn ##add-imm? ] [ drop f ] if ;
+! XXX the vregs that slot>> vreg>insn uses are not necessarily available
: simplify-slot-addressing ( insn -- insn/f )
dup simplify-slot-addressing? [
clone dup slot>> vreg>insn