commit 316b57e37eb10cc127526886f58f6cad24916bf1
parent f1c865f4bc7dff5a5d844049a73ad82463186e9f
Author: Quentin Carbonneaux <quentin@c9x.me>
Date: Tue, 5 Feb 2019 11:48:20 +0100
new spiller heuristic for loops
If a variable is spilled in a loop, the
spiller now tries to keep it spilled over
the whole loop.
Thanks to Michael Forney for sharing a test
case exhibiting a pathological reload.
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/spill.c b/spill.c
@@ -360,12 +360,17 @@ spill(Fn *fn)
bsunion(v, u);
}
} else if (s1) {
- liveon(v, b, s1);
+ /* avoid reloading temporaries
+ * in the middle of loops */
+ bszero(v);
+ liveon(w, b, s1);
+ if (s1->loop >= b->loop)
+ bsunion(v, w);
if (s2) {
liveon(u, b, s2);
- bscopy(w, u);
- bsinter(w, v);
- bsunion(v, u);
+ if (s2->loop >= b->loop)
+ bsunion(v, u);
+ bsinter(w, u);
}
limit2(v, 0, 0, w);
} else {