polserver/testsuite/escript/opt
Eric Swanson cc1b0c6ee3 fix optimizer bug: can stop optimizing prematurely if pre- or post-decrement operators are present
optimize_token() is meant to return true only if it performs an optimization.

By returning true when it did not, it makes the optimizer stop trying.

A script like this can trigger the condition:

var i := 3;
var ii;

ii := 1 - (--i);
print(i);
print(ii);

Notice that line 4 does not optimize to an 'assign-consume' and therefore does not optimize to 'assign global`

Listfile before (see instructions 6-12):

/vagrant/testsuite/escript/opt/opt005-stopped-optimizing-early.src, Line 1
var i := 3;
0: decl global #0
1: 3L
2: :=
3: #
var ii;
4: decl global #1
5: #
ii := 1 - (--i);
6: global #1
7: 1L
8: global #0
9: unary --
10: -
11: :=
12: #
print(i);
13: global #0
14: Func(1,0): Print
15: #
print(ii);
16: global #1
17: Func(1,0): Print
18: #
19: progend

Listfile after (see instructions 6-10):

/vagrant/testsuite/escript/opt/opt005-stopped-optimizing-early.src, Line 1
var i := 3;
0: decl global #0
1: 3L
2: :=
3: #
var ii;
4: decl global #1
5: #
ii := 1 - (--i);
6: 1L
7: global #0
8: unary --
9: -
10: global1 :=
print(i);
11: global #0
12: Func(1,0): Print
13: #
print(ii);
14: global #1
15: Func(1,0): Print
16: #
17: progend
2020-07-29 20:42:07 -07:00
..
opt001.out Unit Tests: putting some orde rin escript unit tests 2015-12-19 02:31:08 +01:00
opt001.src Unit Tests: putting some orde rin escript unit tests 2015-12-19 02:31:08 +01:00
opt002.out Unit Tests: putting some orde rin escript unit tests 2015-12-19 02:31:08 +01:00
opt002.src Unit Tests: putting some orde rin escript unit tests 2015-12-19 02:31:08 +01:00
opt003.out Unit Tests: putting some orde rin escript unit tests 2015-12-19 02:31:08 +01:00
opt003.src Unit Tests: putting some orde rin escript unit tests 2015-12-19 02:31:08 +01:00
opt004.out Unit Tests: putting some orde rin escript unit tests 2015-12-19 02:31:08 +01:00
opt004.src Unit Tests: putting some orde rin escript unit tests 2015-12-19 02:31:08 +01:00
opt005-stopped-optimizing-early.src fix optimizer bug: can stop optimizing prematurely if pre- or post-decrement operators are present 2020-07-29 20:42:07 -07:00