diff options
Diffstat (limited to 'src/passes/AvoidReinterprets.cpp')
-rw-r--r-- | src/passes/AvoidReinterprets.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/passes/AvoidReinterprets.cpp b/src/passes/AvoidReinterprets.cpp index c2607725d..feea4871f 100644 --- a/src/passes/AvoidReinterprets.cpp +++ b/src/passes/AvoidReinterprets.cpp @@ -115,11 +115,11 @@ struct AvoidReinterprets : public WalkerPass<PostWalker<AvoidReinterprets>> { void optimize(Function* func) { std::set<Load*> unoptimizables; - auto indexType = getModule()->memory.indexType; for (auto& [load, info] : infos) { if (info.reinterpreted && canReplaceWithReinterpret(load)) { // We should use another load here, to avoid reinterprets. - info.ptrLocal = Builder::addVar(func, indexType); + auto mem = getModule()->getMemory(load->memory); + info.ptrLocal = Builder::addVar(func, mem->indexType); info.reinterpretedLocal = Builder::addVar(func, load->type.reinterpret()); } else { @@ -173,7 +173,8 @@ struct AvoidReinterprets : public WalkerPass<PostWalker<AvoidReinterprets>> { auto& info = iter->second; Builder builder(*module); auto* ptr = curr->ptr; - auto indexType = getModule()->memory.indexType; + auto mem = getModule()->getMemory(curr->memory); + auto indexType = mem->indexType; curr->ptr = builder.makeLocalGet(info.ptrLocal, indexType); // Note that the other load can have its sign set to false - if the // original were an integer, the other is a float anyhow; and if @@ -195,7 +196,8 @@ struct AvoidReinterprets : public WalkerPass<PostWalker<AvoidReinterprets>> { load->offset, load->align, ptr, - load->type.reinterpret()); + load->type.reinterpret(), + load->memory); } } finalOptimizer(infos, localGraph, getModule(), getPassOptions()); |