Open
Description
https://webassembly.studio/?f=oeg02m22gmq
export function add_div(x: i32): i32 {
return u32(x) / 100 + x / -100;
}
output:
function main_add_div($0) {
$0 = $0 | 0;
return (($0 | 0) / (-100 | 0) | 0) + (($0 >>> 0) / (100 >>> 0) | 0) | 0 | 0;
}
but I'm expecting single | 0
at the end:
function main_add_div($0) {
$0 = $0 | 0;
return (($0 | 0) / (-100 | 0) | 0) + (($0 >>> 0) / (100 >>> 0) | 0) | 0;
}
similar here
but after extra optimizations it normalized to expected. But I guess it could be done earlier without extra opts?
also since asm2js is more like js code and less than asm.js could we simplify some conversion? Like this one:
function i32_trunc_u_f32($0) {
$0 = Math_fround($0);
return ~~$0 >>> 0 | 0;
}
could be just:
function i32_trunc_u_f32($0) {
$0 = Math_fround($0);
return $0 | 0;
}
And Closure Compiler can't do such optimizations btw
Metadata
Metadata
Assignees
Labels
No labels