diff options
author | Max Graey <maxgraey@gmail.com> | 2021-10-12 20:20:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-12 10:20:30 -0700 |
commit | cd4e0e8ca447158dcc7c7f95cac2adcc43f99094 (patch) | |
tree | c3a899faddfeccbbf160c9ce14b4c6193f076b97 | |
parent | 5071f49988f65a5e8634714a7763ecce414651fe (diff) | |
download | binaryen-cd4e0e8ca447158dcc7c7f95cac2adcc43f99094.tar.gz binaryen-cd4e0e8ca447158dcc7c7f95cac2adcc43f99094.tar.bz2 binaryen-cd4e0e8ca447158dcc7c7f95cac2adcc43f99094.zip |
[Costs] More precise costs for int div & rem (#4229)
Div/rem by a constant can be optimized by VMs, so it is usually
closer to the speed of a mul.
Div on 64-bit (either with or without a constant) can be slower
than 32-bit, so bump that up by one as well.
-rw-r--r-- | src/ir/cost.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/ir/cost.h b/src/ir/cost.h index 7c18a8200..0463d3310 100644 --- a/src/ir/cost.h +++ b/src/ir/cost.h @@ -253,7 +253,7 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, CostType> { case DivUInt32: case RemSInt32: case RemUInt32: - ret = 3; + ret = curr->right->is<Const>() ? 2 : 3; break; case AndInt32: case OrInt32: @@ -274,7 +274,7 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, CostType> { case DivUInt64: case RemSInt64: case RemUInt64: - ret = 3; + ret = curr->right->is<Const>() ? 3 : 4; break; case AndInt64: case OrInt64: |