diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Vacuum.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 43a5f8a09..0e01c0370 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -96,9 +96,12 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> { // it is ok to remove a load if the result is not used, and it has no // side effects (the load itself may trap, if we are not ignoring such // things) + auto* load = curr->cast<Load>(); if (!resultUsed && !EffectAnalyzer(getPassOptions(), curr).hasSideEffects()) { - return curr->cast<Load>()->ptr; + if (!typeMatters || load->ptr->type == type) { + return load->ptr; + } } return curr; } |