Disable redundent assign eliminator for deeply nested loops.

This commit is contained in:
chriseth
2019-04-23 09:50:25 +02:00
parent 4312f6ec23
commit aad4373da4
4 changed files with 202 additions and 10 deletions
@@ -0,0 +1,88 @@
{
let x := 1
let y := 2
let a := 3
let b := 4
for {} 1 {} {
for {} 1 {} {
for {} 1 {} {
// Here, the nesting is not yet too deep, so the assignment
// should be removed.
for {} 1 { x := 9 } {
y := 10
for {} 1 {} {
for {} 1 {} {
// Now we are too deep, assignments stay.
for {} 1 { a := 10 } {
b := 12
b := 11
}
}
}
}
}
}
}
x := 13
}
// ====
// step: redundantAssignEliminator
// ----
// {
// let x := 1
// let y := 2
// let a := 3
// let b := 4
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// a := 10
// }
// {
// b := 12
// b := 11
// }
// }
// }
// }
// }
// }
// }
// }
@@ -0,0 +1,76 @@
{
for {} 1 {} {
for {} 1 {} {
for {} 1 {} {
for {} 1 {} {
for {} 1 {} {
for {} 1 {} {
for {} 1 { let a := 1 a := 2 a := 3 } {
// Declarations inside body and post should be handled as normal.
let b := 1
b := 2
b := 3
}
}
}
}
}
}
}
}
// ====
// step: redundantAssignEliminator
// ----
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// }
// {
// for {
// }
// 1
// {
// let a := 1
// }
// {
// let b := 1
// }
// }
// }
// }
// }
// }
// }
// }