[PATCH] D65336: [InstSimplify] remove quadratic time looping (PR42771)

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 26 09:29:28 PDT 2019


foad added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp:45-48
         // Don't waste time simplifying unused instructions.
-        if (!I->use_empty()) {
-          if (Value *V = SimplifyInstruction(I, SQ, ORE)) {
-            // Mark all uses for resimplification next time round the loop.
-            for (User *U : I->users())
-              Next->insert(cast<Instruction>(U));
-            I->replaceAllUsesWith(V);
-            ++NumSimplified;
-            Changed = true;
-          }
-        }
-        if (RecursivelyDeleteTriviallyDeadInstructions(I, SQ.TLI)) {
-          // RecursivelyDeleteTriviallyDeadInstruction can remove more than one
-          // instruction, so simply incrementing the iterator does not work.
-          // When instructions get deleted re-iterate instead.
-          BI = BB->begin();
-          BE = BB->end();
+        if (isInstructionTriviallyDead(&I)) {
+          DeadInstsInBB.push_back(&I);
+        } else if (Value *V = SimplifyInstruction(&I, SQ, ORE)) {
----------------
Why did you change the logic here? Now we might try to simplify an instruction that has no uses but is not trivially dead, which at least makes the comment on L45 slightly wrong.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65336/new/

https://reviews.llvm.org/D65336





More information about the llvm-commits mailing list