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,24 @@
var global = "";
function foo(x) {
global += x;
return x;
}
function box() {
var i = 0;
do {
++i;
if (i == 5) {
continue
}
global += ";";
if (foo(i) >= 10) {
break;
}
} while (true);
if (global != ";1;2;3;4;6;7;8;9;10") return "fail: " + global;
return "OK"
}