[llvm] [SPIRV] Avoid repeated hash lookups (NFC) (PR #130391)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 7 19:55:29 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-spir-v
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/130391.diff
1 Files Affected:
- (modified) llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp (+4-3)
``````````diff
diff --git a/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp b/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
index baacd58b28028..3779a4b6ccd34 100644
--- a/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
@@ -120,8 +120,9 @@ addConstantsToTrack(MachineFunction &MF, SPIRVGlobalRegistry *GR,
}
for (MachineInstr *MI : ToErase) {
Register Reg = MI->getOperand(2).getReg();
- if (RegsAlreadyAddedToDT.contains(MI))
- Reg = RegsAlreadyAddedToDT[MI];
+ auto It = RegsAlreadyAddedToDT.find(MI);
+ if (It != RegsAlreadyAddedToDT.end())
+ Reg = It->second;
auto *RC = MRI.getRegClassOrNull(MI->getOperand(0).getReg());
if (!MRI.getRegClassOrNull(Reg) && RC)
MRI.setRegClass(Reg, RC);
@@ -652,7 +653,7 @@ generateAssignInstrs(MachineFunction &MF, SPIRVGlobalRegistry *GR,
}
for (MachineInstr *MI : ToErase) {
auto It = RegsAlreadyAddedToDT.find(MI);
- if (RegsAlreadyAddedToDT.contains(MI))
+ if (It != RegsAlreadyAddedToDT.end())
MRI.replaceRegWith(MI->getOperand(0).getReg(), It->second);
MI->eraseFromParent();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/130391
More information about the llvm-commits
mailing list