[llvm] [CodeGen] Avoid repeated hash lookups (NFC) (PR #131722)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 17 22:09:07 PDT 2025


================
@@ -916,13 +916,15 @@ SDValue SelectionDAGBuilder::LowerAsSTATEPOINT(
     bool IsLocal = (Relocate->getParent() == StatepointInstr->getParent());
 
     RecordType Record;
-    if (IsLocal && LowerAsVReg.count(SDV)) {
-      // Result is already stored in StatepointLowering
-      Record.type = RecordType::SDValueNode;
-    } else if (LowerAsVReg.count(SDV)) {
-      Record.type = RecordType::VReg;
-      assert(VirtRegs.count(SDV));
-      Record.payload.Reg = VirtRegs[SDV];
+    if (LowerAsVReg.count(SDV)) {
+      if (IsLocal) {
+        // Result is already stored in StatepointLowering
+        Record.type = RecordType::SDValueNode;
+      } else {
+        Record.type = RecordType::VReg;
+        assert(VirtRegs.count(SDV));
+        Record.payload.Reg = VirtRegs[SDV];
----------------
kazutakahirata wrote:

OK.  I've switched to `VirtRegs.find()` here.  I don't really want to use `insert` when I don't mean to insert a new element although `insert` would let me skip the pesky comparison against `VirtRegs.end()`.

See the latest revision.  Thanks!

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


More information about the llvm-commits mailing list