IR: optimize f(); return in tailrec fun f(): Unit

It's equivalent to `return f()`.
This commit is contained in:
pyos
2021-09-06 11:25:14 +02:00
committed by Mikhael Bogdanov
parent 83364d78f5
commit b2315a4a05
3 changed files with 50 additions and 37 deletions
@@ -7,14 +7,14 @@
// IGNORE_BACKEND: JS
tailrec fun test(x : Int) : Unit {
if (x == 1) {
if (x > 800000) {
test(x - 1)
} else if (x == 2) {
} else if (x > 600000) {
test(x - 1)
return
} else if (x == 3) {
<!NON_TAIL_RECURSIVE_CALL!>test<!>(x - 1)
if (x == 3) {
} else if (x > 400000) {
<!NON_TAIL_RECURSIVE_CALL!>test<!>(1)
if (x > 200000) {
test(x - 1)
}
return