[llvm] [CanonicalizeFreezeInLoops] fix duplicate removal (PR #74716)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 8 01:39:42 PST 2023


================
@@ -151,11 +151,18 @@ bool CanonicalizeFreezeInLoopsImpl::run() {
       }
     }
 
+    bool Exist = false;
     auto Visit = [&](User *U) {
       if (auto *FI = dyn_cast<FreezeInst>(U)) {
-        LLVM_DEBUG(dbgs() << "canonfr: found: " << *FI << "\n");
-        Info.FI = FI;
-        Candidates.push_back(Info);
+        for (const auto &Candidate : Candidates) {
----------------
fhahn wrote:

How about instead changing Candidates to a SetVector as suggested by @nikic at the issue? I suppose it would require specializing `DenseMapInfo` for `FrozenIndPHIInfo`. See https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Analysis/MemoryLocation.h#L330 for an example

https://github.com/llvm/llvm-project/pull/74716


More information about the llvm-commits mailing list