From cd4e0e8ca447158dcc7c7f95cac2adcc43f99094 Mon Sep 17 00:00:00 2001 From: Max Graey Date: Tue, 12 Oct 2021 20:20:30 +0300 Subject: [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. --- src/ir/cost.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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 { case DivUInt32: case RemSInt32: case RemUInt32: - ret = 3; + ret = curr->right->is() ? 2 : 3; break; case AndInt32: case OrInt32: @@ -274,7 +274,7 @@ struct CostAnalyzer : public OverriddenVisitor { case DivUInt64: case RemSInt64: case RemUInt64: - ret = 3; + ret = curr->right->is() ? 3 : 4; break; case AndInt64: case OrInt64: -- cgit v1.2.3