File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -951,16 +951,30 @@ bool RLEContext::run() {
951
951
} while (ForwardSetChanged || LastIteration);
952
952
953
953
// Finally, perform the redundant load replacements.
954
+ llvm::DenseSet<SILInstruction *> InstsToRemove;
954
955
bool SILChanged = false ;
955
956
for (auto &X : BBToLocState) {
956
957
for (auto &F : X.second .getRL ()) {
957
958
DEBUG (llvm::dbgs () << " Replacing " << SILValue (F.first ) << " With "
958
959
<< F.second );
959
960
SILChanged = true ;
960
961
SILValue (F.first ).replaceAllUsesWith (F.second );
962
+ InstsToRemove.insert (F.first );
961
963
++NumForwardedLoads;
962
964
}
963
965
}
966
+
967
+ // Erase the instructions recursively, this way, we get rid of pass
968
+ // dependence on DCE.
969
+ for (auto &X : InstsToRemove) {
970
+ // It is possible that the instruction still has uses, because it could be
971
+ // used as the replacement Value, i.e. F.second, for some other RLE pairs.
972
+ //
973
+ // TODO: we should fix this, otherwise we are missing RLE opportunities.
974
+ if (!X->use_empty ())
975
+ continue ;
976
+ recursivelyDeleteTriviallyDeadInstructions (X, true );
977
+ }
964
978
return SILChanged;
965
979
}
966
980
You can’t perform that action at this time.
0 commit comments