]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/value-numbering/value-numbering-tests.factor
Merge branch 'master' into experimental (untested!)
[factor.git] / basis / compiler / cfg / value-numbering / value-numbering-tests.factor
1 IN: compiler.cfg.value-numbering.tests
2 USING: compiler.cfg.value-numbering compiler.cfg.instructions
3 compiler.cfg.registers compiler.cfg.debugger cpu.architecture
4 tools.test kernel math combinators.short-circuit accessors
5 sequences ;
6
7 : trim-temps ( insns -- insns )
8     [
9         dup {
10             [ ##compare? ]
11             [ ##compare-imm? ]
12             [ ##compare-float? ]
13         } 1|| [ f >>temp ] when
14     ] map ;
15
16 [
17     {
18         T{ ##peek f V int-regs 45 D 1 }
19         T{ ##copy f V int-regs 48 V int-regs 45 }
20         T{ ##compare-imm-branch f V int-regs 45 7 cc/= }
21     }
22 ] [
23     {
24         T{ ##peek f V int-regs 45 D 1 }
25         T{ ##copy f V int-regs 48 V int-regs 45 }
26         T{ ##compare-imm-branch f V int-regs 48 7 cc/= }
27     } value-numbering
28 ] unit-test
29
30 [
31     {
32         T{ ##load-immediate f V int-regs 2 8 }
33         T{ ##peek f V int-regs 3 D 0 }
34         T{ ##slot-imm f V int-regs 4 V int-regs 3 1 3 }
35         T{ ##replace f V int-regs 4 D 0 }
36     }
37 ] [
38     {
39         T{ ##load-immediate f V int-regs 2 8 }
40         T{ ##peek f V int-regs 3 D 0 }
41         T{ ##slot-imm f V int-regs 4 V int-regs 3 1 3 }
42         T{ ##replace f V int-regs 4 D 0 }
43     } value-numbering
44 ] unit-test
45
46 [ t ] [
47     {
48         T{ ##peek f V int-regs 1 D 0 }
49         T{ ##dispatch f V int-regs 1 V int-regs 2 0 }
50     } dup value-numbering =
51 ] unit-test
52
53 [ t ] [
54     {
55         T{ ##peek f V int-regs 16 D 0 }
56         T{ ##peek f V int-regs 17 D -1 }
57         T{ ##sar-imm f V int-regs 18 V int-regs 17 3 }
58         T{ ##add-imm f V int-regs 19 V int-regs 16 13 }
59         T{ ##add f V int-regs 21 V int-regs 18 V int-regs 19 }
60         T{ ##alien-unsigned-1 f V int-regs 22 V int-regs 21 }
61         T{ ##shl-imm f V int-regs 23 V int-regs 22 3 }
62         T{ ##replace f V int-regs 23 D 0 }
63     } dup value-numbering =
64 ] unit-test
65
66 [
67     {
68         T{ ##peek f V int-regs 1 D 0 }
69         T{ ##shl-imm f V int-regs 2 V int-regs 1 3 }
70         T{ ##shr-imm f V int-regs 3 V int-regs 2 3 }
71         T{ ##replace f V int-regs 1 D 0 }
72     }
73 ] [
74     {
75         T{ ##peek f V int-regs 1 D 0 }
76         T{ ##mul-imm f V int-regs 2 V int-regs 1 8 }
77         T{ ##shr-imm f V int-regs 3 V int-regs 2 3 }
78         T{ ##replace f V int-regs 3 D 0 }
79     } value-numbering
80 ] unit-test
81
82 [
83     {
84         T{ ##load-indirect f V int-regs 1 + }
85         T{ ##peek f V int-regs 2 D 0 }
86         T{ ##compare f V int-regs 4 V int-regs 2 V int-regs 1 cc> }
87         T{ ##compare f V int-regs 6 V int-regs 2 V int-regs 1 cc> }
88         T{ ##replace f V int-regs 4 D 0 }
89     }
90 ] [
91     {
92         T{ ##load-indirect f V int-regs 1 + }
93         T{ ##peek f V int-regs 2 D 0 }
94         T{ ##compare f V int-regs 4 V int-regs 2 V int-regs 1 cc> }
95         T{ ##compare-imm f V int-regs 6 V int-regs 4 7 cc/= }
96         T{ ##replace f V int-regs 6 D 0 }
97     } value-numbering trim-temps
98 ] unit-test
99
100 [
101     {
102         T{ ##load-indirect f V int-regs 1 + }
103         T{ ##peek f V int-regs 2 D 0 }
104         T{ ##compare f V int-regs 4 V int-regs 2 V int-regs 1 cc<= }
105         T{ ##compare f V int-regs 6 V int-regs 2 V int-regs 1 cc> }
106         T{ ##replace f V int-regs 6 D 0 }
107     }
108 ] [
109     {
110         T{ ##load-indirect f V int-regs 1 + }
111         T{ ##peek f V int-regs 2 D 0 }
112         T{ ##compare f V int-regs 4 V int-regs 2 V int-regs 1 cc<= }
113         T{ ##compare-imm f V int-regs 6 V int-regs 4 7 cc= }
114         T{ ##replace f V int-regs 6 D 0 }
115     } value-numbering trim-temps
116 ] unit-test
117
118 [
119     {
120         T{ ##peek f V int-regs 8 D 0 }
121         T{ ##peek f V int-regs 9 D -1 }
122         T{ ##unbox-float f V double-float-regs 10 V int-regs 8 }
123         T{ ##unbox-float f V double-float-regs 11 V int-regs 9 }
124         T{ ##compare-float f V int-regs 12 V double-float-regs 10 V double-float-regs 11 cc< }
125         T{ ##compare-float f V int-regs 14 V double-float-regs 10 V double-float-regs 11 cc>= }
126         T{ ##replace f V int-regs 14 D 0 }
127     }
128 ] [
129     {
130         T{ ##peek f V int-regs 8 D 0 }
131         T{ ##peek f V int-regs 9 D -1 }
132         T{ ##unbox-float f V double-float-regs 10 V int-regs 8 }
133         T{ ##unbox-float f V double-float-regs 11 V int-regs 9 }
134         T{ ##compare-float f V int-regs 12 V double-float-regs 10 V double-float-regs 11 cc< }
135         T{ ##compare-imm f V int-regs 14 V int-regs 12 7 cc= }
136         T{ ##replace f V int-regs 14 D 0 }
137     } value-numbering trim-temps
138 ] unit-test
139
140 [
141     {
142         T{ ##peek f V int-regs 29 D -1 }
143         T{ ##peek f V int-regs 30 D -2 }
144         T{ ##compare f V int-regs 33 V int-regs 29 V int-regs 30 cc<= }
145         T{ ##compare-branch f V int-regs 29 V int-regs 30 cc<= }
146     }
147 ] [
148     {
149         T{ ##peek f V int-regs 29 D -1 }
150         T{ ##peek f V int-regs 30 D -2 }
151         T{ ##compare f V int-regs 33 V int-regs 29 V int-regs 30 cc<= }
152         T{ ##compare-imm-branch f V int-regs 33 7 cc/= }
153     } value-numbering trim-temps
154 ] unit-test