Skip to content

Commit 5d2393a

Browse files
[InstCombine] Avoid repeated hash lookups (NFC) (#124243)
1 parent ec66c4a commit 5d2393a

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3060,14 +3060,10 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
30603060
unsigned SrcElemsPerTgtElem = TgtElemBitWidth / SrcElemBitWidth;
30613061
assert(SrcElemsPerTgtElem);
30623062
BegIdx /= SrcElemsPerTgtElem;
3063-
bool BCAlreadyExists = NewBCs.contains(CastSrcTy);
3064-
auto *NewBC =
3065-
BCAlreadyExists
3066-
? NewBCs[CastSrcTy]
3067-
: Builder.CreateBitCast(V, CastSrcTy, SVI.getName() + ".bc");
3068-
if (!BCAlreadyExists)
3069-
NewBCs[CastSrcTy] = NewBC;
3070-
auto *Ext = Builder.CreateExtractElement(NewBC, BegIdx,
3063+
auto [It, Inserted] = NewBCs.try_emplace(CastSrcTy);
3064+
if (Inserted)
3065+
It->second = Builder.CreateBitCast(V, CastSrcTy, SVI.getName() + ".bc");
3066+
auto *Ext = Builder.CreateExtractElement(It->second, BegIdx,
30713067
SVI.getName() + ".extract");
30723068
// The shufflevector isn't being replaced: the bitcast that used it
30733069
// is. InstCombine will visit the newly-created instructions.

0 commit comments

Comments
 (0)