diff options
author | Max Graey <maxgraey@gmail.com> | 2020-09-14 04:04:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-13 18:04:38 -0700 |
commit | cd9bd149162ecdd9f2715367617771ea55b7cd7e (patch) | |
tree | 197641f370ab9560f2edd64700178344910b7b07 /test/passes/optimize-instructions_all-features.wast | |
parent | 643facd9bf6af1792db473e73e16983df940106f (diff) | |
download | binaryen-cd9bd149162ecdd9f2715367617771ea55b7cd7e.tar.gz binaryen-cd9bd149162ecdd9f2715367617771ea55b7cd7e.tar.bz2 binaryen-cd9bd149162ecdd9f2715367617771ea55b7cd7e.zip |
Simplify subtracting zero from float expressions (#3125)
`x - 0.0` -> `x`
`x + (-0.0)` -> `x`
`x - (-0.0)` -> `x + 0.0`
where `x` is `f32` or `f64`.
Diffstat (limited to 'test/passes/optimize-instructions_all-features.wast')
-rw-r--r-- | test/passes/optimize-instructions_all-features.wast | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/passes/optimize-instructions_all-features.wast b/test/passes/optimize-instructions_all-features.wast index c2fa16e35..c67270a4f 100644 --- a/test/passes/optimize-instructions_all-features.wast +++ b/test/passes/optimize-instructions_all-features.wast @@ -4047,6 +4047,53 @@ (i32.const 2) ) ) + (func $const-float-zero (param $fx f32) (param $fy f64) + ;; x - 0.0 ==> x + (drop (f32.sub + (local.get $fx) + (f32.const 0) + )) + (drop (f64.sub + (local.get $fy) + (f64.const 0) + )) + ;; x + (-0.0) ==> x + (drop (f32.add + (local.get $fx) + (f32.const -0) + )) + (drop (f64.add + (local.get $fy) + (f64.const -0) + )) + ;; x - (-0.0) ==> x + 0.0 + (drop (f32.sub + (local.get $fx) + (f32.const -0) ;; skip + )) + (drop (f64.sub + (local.get $fy) + (f64.const -0) ;; skip + )) + ;; 0.0 - x ==> 0.0 - x + (drop (f32.sub + (f32.const 0) + (local.get $fx) ;; skip + )) + (drop (f64.sub + (f64.const 0) + (local.get $fy) ;; skip + )) + ;; x + 0.0 ==> x + 0.0 + (drop (f32.add + (local.get $fx) ;; skip + (f32.const 0) + )) + (drop (f64.add + (local.get $fy) ;; skip + (f64.const 0) + )) + ) (func $rhs-is-neg-one (param $x i32) (param $y i64) (param $fx f32) (param $fy f64) (drop (i32.sub (local.get $x) |