KT-12275 Add JS optimization that transforms the following code

```
do {
    X
    if (B) break;
} while (A)
```

to

```
do {
    X
} while (!B && A)
```

Add inversion that takes boolean expression and applies negation to it, simplifying if possible (like !!a => a).
This commit is contained in:
Alexey Andreev
2016-05-16 13:08:44 +03:00
parent b3d29adad9
commit 05dd039151
27 changed files with 812 additions and 1 deletions
@@ -0,0 +1,20 @@
var global = "";
function foo(x) {
global += x + ";";
return x;
}
function box() {
var i = 1;
var sum = 0;
do {
sum += i;
i++;
} while (foo(i) < 10 && foo(sum) <= 30);
if (global != "2;1;3;3;4;6;5;10;6;15;7;21;8;28;9;36;") return "fail1: " + global;
if (sum != 36) return "fail2: " + sum;
return "OK"
}