summaryrefslogtreecommitdiff
path: root/src/passes/OptimizeInstructions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r--src/passes/OptimizeInstructions.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index cb656ceaf..3153af200 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -1190,6 +1190,19 @@ struct OptimizeInstructions
return;
}
+ if (auto* get = curr->target->dynCast<TableGet>()) {
+ // (call_ref ..args.. (table.get $table (index))
+ // =>
+ // (call_indirect $table ..args.. (index))
+ replaceCurrent(Builder(*getModule())
+ .makeCallIndirect(get->table,
+ get->index,
+ curr->operands,
+ get->type.getHeapType().getSignature(),
+ curr->isReturn));
+ return;
+ }
+
auto features = getModule()->features;
// It is possible the target is not a function reference, but we can infer