Index: src/IceCfg.cpp |
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp |
index ed962d151f43b11d980ede9898db01912ee843f7..04e7acd25a6c0286da9f9bad9b4b93361ddf226b 100644 |
--- a/src/IceCfg.cpp |
+++ b/src/IceCfg.cpp |
@@ -284,6 +284,19 @@ bool Cfg::validateLiveness() const { |
return Valid; |
} |
+// Deletes redundant assignments like "var=var". This includes |
+// architecturally redundant moves like "var1:eax=var2:eax". As such, |
+// this needs to be done very late in the translation to avoid |
+// liveness inconsistencies. |
+void Cfg::deleteRedundantAssignments() { |
+ for (CfgNode *Node : Nodes) { |
+ // Ignore Phi instructions. |
+ for (Inst *I : Node->getInsts()) |
+ if (I->isRedundantAssign()) |
+ I->setDeleted(); |
+ } |
+} |
+ |
void Cfg::doBranchOpt() { |
TimerMarker T(TimerStack::TT_doBranchOpt, this); |
for (auto I = Nodes.begin(), E = Nodes.end(); I != E; ++I) { |