promote: list what has effects once, not every liveness round
Liveness runs again each time an empty branch folds (up to 10 rounds on the largest functions), and each round scanned every instruction for the ones with effects. That list does not change between rounds. The hill-climbing set: promotion -16%; output unchanged on the verify corpus.
This commit is contained in:
parent
ec64ffa4b0
commit
dfb629ace0
|
|
@ -623,6 +623,9 @@ pub fn run(a: Allocator, m: *module.Module, func: u32, dyn: *const std.AutoHashM
|
||||||
// transitively; new phis likewise. (The loads promotion leaves dead,
|
// transitively; new phis likewise. (The loads promotion leaves dead,
|
||||||
// such as copies of arguments never read, go too.)
|
// such as copies of arguments never read, go too.)
|
||||||
const live = try a.alloc(bool, n + np);
|
const live = try a.alloc(bool, n + np);
|
||||||
|
// (What has effects, worked out once for every round.)
|
||||||
|
var effects: std.ArrayList(u32) = .empty;
|
||||||
|
for (insts, 0..) |inst, i| if (!removed[i] and hasEffects(m, inst)) try effects.append(a, @intCast(i));
|
||||||
while (true) {
|
while (true) {
|
||||||
@memset(live, false);
|
@memset(live, false);
|
||||||
{
|
{
|
||||||
|
|
@ -647,9 +650,9 @@ pub fn run(a: Allocator, m: *module.Module, func: u32, dyn: *const std.AutoHashM
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var mark: Mark = .{ .repl = repl, .live = live, .removed = removed, .work = &work, .a = a };
|
var mark: Mark = .{ .repl = repl, .live = live, .removed = removed, .work = &work, .a = a };
|
||||||
for (insts, 0..) |inst, i| if (!removed[i] and hasEffects(m, inst) and (reach[block_of[i]] or i == block_start[block_of[i] + 1] - 1)) {
|
for (effects.items) |i| if (reach[block_of[i]] or i == block_start[block_of[i] + 1] - 1) {
|
||||||
live[i] = true;
|
live[i] = true;
|
||||||
try work.append(a, @intCast(i));
|
try work.append(a, i);
|
||||||
};
|
};
|
||||||
while (work.pop()) |x| {
|
while (work.pop()) |x| {
|
||||||
if (x < n) {
|
if (x < n) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue