]> granicus.if.org Git - llvm/commitdiff
NewGVN: Reverse order of congruence class elimination to maximize trivial deadness
authorDaniel Berlin <dberlin@dberlin.org>
Sun, 12 Feb 2017 23:24:45 +0000 (23:24 +0000)
committerDaniel Berlin <dberlin@dberlin.org>
Sun, 12 Feb 2017 23:24:45 +0000 (23:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294926 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/NewGVN.cpp

index 25455c75b4e0591fa2af0549aab81a70877119f1..ab195e4000c8788547f9937f746a4673f8e58dae 100644 (file)
@@ -2059,7 +2059,7 @@ void NewGVN::convertDenseToLoadsAndStores(
 }
 
 static void patchReplacementInstruction(Instruction *I, Value *Repl) {
-    auto *ReplInst = dyn_cast<Instruction>(Repl);
+  auto *ReplInst = dyn_cast<Instruction>(Repl);
   if (!ReplInst)
     return;
 
@@ -2220,7 +2220,7 @@ bool NewGVN::eliminateInstructions(Function &F) {
     }
   }
 
-  for (CongruenceClass *CC : CongruenceClasses) {
+  for (CongruenceClass *CC : reverse(CongruenceClasses)) {
     // Track the equivalent store info so we can decide whether to try
     // dead store elimination.
     SmallVector<ValueDFS, 8> PossibleDeadStores;