Skip to content

Extend getMaxbits to handle Block type #7590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 3, 2025
Prev Previous commit
Next Next commit
Refactor getMaxBitsForLocal
  • Loading branch information
xuruiyang2002 committed May 30, 2025
commit 4706fb9b022c377d585a4f7cf8822c81a25dd308
18 changes: 4 additions & 14 deletions src/passes/OptimizeInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2589,20 +2589,10 @@ struct OptimizeInstructions
// check what we know about the local (we may know nothing, if this local
// was added after the pass scanned for locals; in that case, full
// optimization may require another cycle)
if (localInfo.size() <= get->index) {
// we don't know anything about this local
switch (get->type.getBasic()) {
case Type::i32:
return 32;
case Type::i64:
return 64;
case Type::unreachable:
return 64; // not interesting, but don't crash
default:
WASM_UNREACHABLE("invalid type");
}
}
return localInfo[get->index].maxBits;
if (get->index < localInfo.size()) {
return localInfo[get->index].maxBits;
}
return getBitsForType(get->type);
}

private:
Expand Down
Loading