summaryrefslogtreecommitdiff
path: root/src/passes/LocalCSE.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/LocalCSE.cpp')
-rw-r--r--src/passes/LocalCSE.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/passes/LocalCSE.cpp b/src/passes/LocalCSE.cpp
index 0816bf6ea..b49c92310 100644
--- a/src/passes/LocalCSE.cpp
+++ b/src/passes/LocalCSE.cpp
@@ -172,9 +172,12 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> {
void handle(Expression* curr) {
if (auto* set = curr->dynCast<LocalSet>()) {
// Calculate equivalences
+ auto* func = getFunction();
equivalences.reset(set->index);
if (auto* get = set->value->dynCast<LocalGet>()) {
- equivalences.add(set->index, get->index);
+ if (func->getLocalType(set->index) == func->getLocalType(get->index)) {
+ equivalences.add(set->index, get->index);
+ }
}
// consider the value
auto* value = set->value;
@@ -184,7 +187,7 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> {
if (iter != usables.end()) {
// already exists in the table, this is good to reuse
auto& info = iter->second;
- Type localType = getFunction()->getLocalType(info.index);
+ Type localType = func->getLocalType(info.index);
set->value =
Builder(*getModule()).makeLocalGet(info.index, localType);
anotherPass = true;