[llvm] 5d2393a - [InstCombine] Avoid repeated hash lookups (NFC) (#124243)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 24 08:09:24 PST 2025
Author: Kazu Hirata
Date: 2025-01-24T08:09:20-08:00
New Revision: 5d2393a222c751723b0906485bf90a28dd4e564b
URL: https://github.com/llvm/llvm-project/commit/5d2393a222c751723b0906485bf90a28dd4e564b
DIFF: https://github.com/llvm/llvm-project/commit/5d2393a222c751723b0906485bf90a28dd4e564b.diff
LOG: [InstCombine] Avoid repeated hash lookups (NFC) (#124243)
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index a9ae09b8dba438..6860a7cd07b780 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -3060,14 +3060,10 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
unsigned SrcElemsPerTgtElem = TgtElemBitWidth / SrcElemBitWidth;
assert(SrcElemsPerTgtElem);
BegIdx /= SrcElemsPerTgtElem;
- bool BCAlreadyExists = NewBCs.contains(CastSrcTy);
- auto *NewBC =
- BCAlreadyExists
- ? NewBCs[CastSrcTy]
- : Builder.CreateBitCast(V, CastSrcTy, SVI.getName() + ".bc");
- if (!BCAlreadyExists)
- NewBCs[CastSrcTy] = NewBC;
- auto *Ext = Builder.CreateExtractElement(NewBC, BegIdx,
+ auto [It, Inserted] = NewBCs.try_emplace(CastSrcTy);
+ if (Inserted)
+ It->second = Builder.CreateBitCast(V, CastSrcTy, SVI.getName() + ".bc");
+ auto *Ext = Builder.CreateExtractElement(It->second, BegIdx,
SVI.getName() + ".extract");
// The shufflevector isn't being replaced: the bitcast that used it
// is. InstCombine will visit the newly-created instructions.
More information about the llvm-commits
mailing list