summaryrefslogtreecommitdiff
path: root/src/passes/Precompute.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/Precompute.cpp')
-rw-r--r--src/passes/Precompute.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp
index 074dd832c..02fd089ec 100644
--- a/src/passes/Precompute.cpp
+++ b/src/passes/Precompute.cpp
@@ -163,20 +163,24 @@ struct Precompute
void visitExpression(Expression* curr) {
// TODO: if local.get, only replace with a constant if we don't care about
// size...?
- if (curr->is<Const>() || curr->is<Nop>())
+ if (curr->is<Const>() || curr->is<Nop>()) {
return;
+ }
// Until engines implement v128.const and we have SIMD-aware optimizations
// that can break large v128.const instructions into smaller consts and
// splats, do not try to precompute v128 expressions.
- if (isVectorType(curr->type))
+ if (isVectorType(curr->type)) {
return;
+ }
// try to evaluate this into a const
Flow flow = precomputeExpression(curr);
- if (isVectorType(flow.value.type))
+ if (isVectorType(flow.value.type)) {
return;
+ }
if (flow.breaking()) {
- if (flow.breakTo == NOTPRECOMPUTABLE_FLOW)
+ if (flow.breakTo == NOTPRECOMPUTABLE_FLOW) {
return;
+ }
if (flow.breakTo == RETURN_FLOW) {
// this expression causes a return. if it's already a return, reuse the
// node
@@ -301,8 +305,9 @@ private:
// mark it as such and add everything it influences to the work list,
// as they may be constant too.
if (auto* set = curr->dynCast<SetLocal>()) {
- if (setValues[set].isConcrete())
+ if (setValues[set].isConcrete()) {
continue; // already known constant
+ }
auto value = setValues[set] = precomputeValue(set->value);
if (value.isConcrete()) {
for (auto* get : localGraph.setInfluences[set]) {
@@ -311,8 +316,9 @@ private:
}
} else {
auto* get = curr->cast<GetLocal>();
- if (getValues[get].isConcrete())
+ if (getValues[get].isConcrete()) {
continue; // already known constant
+ }
// for this get to have constant value, all sets must agree
Literal value;
bool first = true;