[llvm] [AMDGPU] Avoid repeated hash lookups (NFC) (PR #111787)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 9 20:29:03 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/111787.diff
1 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/R600ISelLowering.cpp (+6-4)
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp b/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp
index 7e4d9d21a0b397..1b88fdd3ab2e1c 100644
--- a/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp
@@ -1647,16 +1647,18 @@ SDValue R600TargetLowering::OptimizeSwizzle(SDValue BuildVector, SDValue Swz[],
BuildVector = CompactSwizzlableVector(DAG, BuildVector, SwizzleRemap);
for (unsigned i = 0; i < 4; i++) {
unsigned Idx = Swz[i]->getAsZExtVal();
- if (SwizzleRemap.contains(Idx))
- Swz[i] = DAG.getConstant(SwizzleRemap[Idx], DL, MVT::i32);
+ auto It = SwizzleRemap.find(Idx);
+ if (It != SwizzleRemap.end())
+ Swz[i] = DAG.getConstant(It->second, DL, MVT::i32);
}
SwizzleRemap.clear();
BuildVector = ReorganizeVector(DAG, BuildVector, SwizzleRemap);
for (unsigned i = 0; i < 4; i++) {
unsigned Idx = Swz[i]->getAsZExtVal();
- if (SwizzleRemap.contains(Idx))
- Swz[i] = DAG.getConstant(SwizzleRemap[Idx], DL, MVT::i32);
+ auto It = SwizzleRemap.find(Idx);
+ if (It != SwizzleRemap.end())
+ Swz[i] = DAG.getConstant(It->second, DL, MVT::i32);
}
return BuildVector;
``````````
</details>
https://github.com/llvm/llvm-project/pull/111787
More information about the llvm-commits
mailing list