HaxeFoundation / HaxeFoundation/haxe

Inlined cost calculation for loop unrolling

Open
#8,856 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Would it be possible to calculate the cost of loop unrolling after inlining?

```hx
class Test {
static function main()
for (i in 0...3) {
switch 4 {
case 0: trace("0");
case 1: trace("1");
case 2: trace("2");
case 3: trace("3");
case 4: trace("4");
case 5: trace("5");
case 6: trace("6");
case 7: trace("7");
case 8: trace("8");
case 9: trace("9");
case 10: trace("10");
case 11: trace("11");
case 12: trace("12");
case 13: trace("13");
case 14: trace("14");
case 15: trace("15");
case 16: trace("16");
}
}
}
```
Generated output:
```js
// Generated by Haxe 4.0.0-rc.5+97d365b7f
(function ($global) { "use strict";
var Test = function() { };
Test.main = function() {
var _g = 0;
while(_g < 3) {
++_g;
console.log("root/program/Test.hx:9:","4");
}
};
Test.main();
})({});
```
http://try-haxe.mrcdk.com/#a09C5

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.