compiler.cfg.value-numbering.comparisons: docs and tests
parent
0394a141d3
commit
1eaa151a3c
|
@ -0,0 +1,23 @@
|
||||||
|
USING: compiler.cfg.instructions help.markup help.syntax kernel ;
|
||||||
|
IN: compiler.cfg.value-numbering.comparisons
|
||||||
|
|
||||||
|
HELP: >test-branch
|
||||||
|
{ $values { "insn" insn } { "insn'" ##test-branch } }
|
||||||
|
{ $description "Converts a " { $link ##compare-integer-imm-branch } " instruction into a " { $link ##test-branch } " instruction." } ;
|
||||||
|
|
||||||
|
HELP: rewrite-into-test?
|
||||||
|
{ $values { "insn" insn } { "?" boolean } }
|
||||||
|
{ $description "Whether the comparison instruction can be rewritten into a test instruction." } ;
|
||||||
|
|
||||||
|
ARTICLE: "compiler.cfg.value-numbering.comparisons" "Comparisons GVN"
|
||||||
|
"Optimizations performed here:"
|
||||||
|
$nl
|
||||||
|
{ $list
|
||||||
|
"Eliminating intermediate boolean values when the result of a comparison is used by a compare-branch."
|
||||||
|
"Folding comparisons where both inputs are literal."
|
||||||
|
"Folding comparisons where both inputs are congruent."
|
||||||
|
"Converting compare instructions into compare-imm instructions."
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
ABOUT: "compiler.cfg.value-numbering.comparisons"
|
|
@ -0,0 +1,10 @@
|
||||||
|
USING: compiler.cfg.comparisons compiler.cfg.instructions
|
||||||
|
compiler.cfg.value-numbering.comparisons cpu.x86.assembler.operands
|
||||||
|
kernel tools.test ;
|
||||||
|
IN: compiler.cfg.value-numbering.comparisons.tests
|
||||||
|
|
||||||
|
{
|
||||||
|
T{ ##test-branch { src1 RAX } { src2 RAX } { cc cc= } }
|
||||||
|
} [
|
||||||
|
RAX 0 cc= f ##compare-integer-imm-branch boa >test-branch
|
||||||
|
] unit-test
|
|
@ -8,14 +8,6 @@ compiler.cfg.value-numbering.rewrite cpu.architecture kernel
|
||||||
math math.order namespaces sequences vectors ;
|
math math.order namespaces sequences vectors ;
|
||||||
IN: compiler.cfg.value-numbering.comparisons
|
IN: compiler.cfg.value-numbering.comparisons
|
||||||
|
|
||||||
! Optimizations performed here:
|
|
||||||
!
|
|
||||||
! 1) Eliminating intermediate boolean values when the result of
|
|
||||||
! a comparison is used by a compare-branch
|
|
||||||
! 2) Folding comparisons where both inputs are literal
|
|
||||||
! 3) Folding comparisons where both inputs are congruent
|
|
||||||
! 4) Converting compare instructions into compare-imm instructions
|
|
||||||
|
|
||||||
: fold-compare-imm? ( insn -- ? )
|
: fold-compare-imm? ( insn -- ? )
|
||||||
src1>> vreg>insn literal-insn? ;
|
src1>> vreg>insn literal-insn? ;
|
||||||
|
|
||||||
|
@ -101,7 +93,7 @@ UNION: general-compare-insn scalar-compare-insn ##test-vector ;
|
||||||
: fold-compare-imm-branch ( insn -- insn/f )
|
: fold-compare-imm-branch ( insn -- insn/f )
|
||||||
evaluate-compare-imm fold-branch ;
|
evaluate-compare-imm fold-branch ;
|
||||||
|
|
||||||
: >test-branch ( insn -- insn )
|
: >test-branch ( insn -- insn' )
|
||||||
[ src1>> ] [ src1>> ] [ cc>> ] tri ##test-branch new-insn ;
|
[ src1>> ] [ src1>> ] [ cc>> ] tri ##test-branch new-insn ;
|
||||||
|
|
||||||
M: ##compare-imm-branch rewrite
|
M: ##compare-imm-branch rewrite
|
||||||
|
|
Loading…
Reference in New Issue