binaryen
binaryen copied to clipboard
[OptimizeInstructions] Simplify rounding or conversions after int to float casts
i32 -> f64 -> i32 rountripping optimizations:
i32(f64(i32(x))) -> x // i32.trunc(_sat)_f64_s(f64.convert_i32_s(x)) -> x
u32(f64(u32(x))) -> x // i32.trunc(_sat)_f64_u(f64.convert_i32_u(x)) -> x
// note assymetric signed / unsigned or unsigned / signed cases can't be simplified in similar way
and rounding after integer to float casts:
ceil(float(int(x))) -> float(int(x))
floor(float(int(x))) -> float(int(x))
trunc(float(int(x))) -> float(int(x))
nearest(float(int(x))) -> float(int(x))
where float = f32 | f64, int = i32 | i64 | u32 | u64
Fuzzed ITERATION: 23237
@tlively could you take a look at this PR please?