[PATCH] D107449: [RISCV] Improve codegen for shuffles with LHS/RHS splats
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 5 09:18:55 PDT 2021
craig.topper added inline comments.
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1986
+ if (IsLHSOrUndefIndex && MaskIndex >= 0)
+ ++LHSIndexCounts.try_emplace(MaskIndex, 0).first->getSecond();
+ if (!IsLHSOrUndefIndex)
----------------
frasercrmck wrote:
> craig.topper wrote:
> > Can this just be
> >
> > ```
> > ++LHSIndexCounts[MaskIndex]
> > ```
> >
> > It should default construct a 0 the first time it is accessed.
> Yeah I hope I'm being overly cautious here, but I wasn't sure. I couldn't find it explicitly documented in the `DenseMap` API unlike for `std::map` and I saw this idiom used elsewhere. From what I can see, the DenseMap implementation is indeed value-initializing (i.e. zero-initializing for `unsigned`) - is that strong enough to rely on?
I think so. I was able to find other places that rely on it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107449/new/
https://reviews.llvm.org/D107449
More information about the llvm-commits
mailing list