summaryrefslogtreecommitdiff
path: root/src/passes
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-05-12 11:15:04 -0700
committerGitHub <noreply@github.com>2022-05-12 11:15:04 -0700
commit2da18b9016454c86258f7f94cf8536d3309c1ffc (patch)
treedc2c2e5764733a594fe70ec494e6e38b72b4d268 /src/passes
parentc458c47557981ad7839954d29e8951c3f02b91ef (diff)
downloadbinaryen-2da18b9016454c86258f7f94cf8536d3309c1ffc.tar.gz
binaryen-2da18b9016454c86258f7f94cf8536d3309c1ffc.tar.bz2
binaryen-2da18b9016454c86258f7f94cf8536d3309c1ffc.zip
Costs: Increase cost of casts (#4661)
Casts involve branches in the VM, so adding a cast in return for removing a branch (like If=>Select) is not beneficial. We don't want to ever do any more casts than we already are.
Diffstat (limited to 'src/passes')
-rw-r--r--src/passes/RemoveUnusedBrs.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp
index f383f669a..3c4723c7f 100644
--- a/src/passes/RemoveUnusedBrs.cpp
+++ b/src/passes/RemoveUnusedBrs.cpp
@@ -85,6 +85,9 @@ static bool canTurnIfIntoBrIf(Expression* ifCondition,
// It can be tuned more later.
const Index TooCostlyToRunUnconditionally = 9;
+static_assert(TooCostlyToRunUnconditionally < CostAnalyzer::Unacceptable,
+ "We never run code unconditionally if it has unacceptable cost");
+
// Check if it is not worth it to run code unconditionally. This
// assumes we are trying to run two expressions where previously
// only one of the two might have executed. We assume here that