[PATCH] D84327: [SCEVExpander] Add helper to clean up instrs inserted while expanding.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 14:10:52 PDT 2020


lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

LG to me, but probably wait a bit for @jroelofs.



================
Comment at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:181
+  SmallVector<Instruction *, 8> getAllInsertedInstructions() const {
+    SmallVector<Instruction *, 8> Result;
+    for (auto &VH : InsertedValues) {
----------------
I think it's not unreasonable to reserve the worst-case final size?


================
Comment at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:450
+  /// instructions added during expansion are removed.
+  bool ResultUsed;
+
----------------
bool ResultUsed = false;


================
Comment at: llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:2543-2544
+  auto InsertedInstructions = Expander.getAllInsertedInstructions();
+  SmallPtrSet<Instruction *, 8> InsertedSet(InsertedInstructions.begin(),
+                                            InsertedInstructions.end());
+  (void)InsertedSet;
----------------
You need to wrap this into `#ifndef NDEBUG`, we won't manage to optimize this out
https://godbolt.org/z/Mhq5P1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84327





More information about the llvm-commits mailing list