================
@@ -1035,8 +1035,11 @@ bool PeepholeOptimizer::findNextSource(RegSubRegPair 
RegSubReg,
         return false;
 
       // Insert the Def -> Use entry for the recently found source.
-      ValueTrackerResult CurSrcRes = RewriteMap.lookup(CurSrcPair);
-      if (CurSrcRes.isValid()) {
+      auto [InsertPt, WasInserted] = RewriteMap.try_emplace(CurSrcPair, Res);
+
+      if (!WasInserted) {
+        ValueTrackerResult CurSrcRes = InsertPt->second;
----------------
kazutakahirata wrote:

You might want to make this const reference because you are not modifying 
`ValueTrackerResult` within this `if` block.  Note that `ValueTrackerResult` 
contains a `SmallVector<RegSubRegPair, 2>`, so it's not completely cheap to 
copy.

```suggestion
        const ValueTrackerResult &CurSrcRes = InsertPt->second;
```

https://github.com/llvm/llvm-project/pull/124531
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to