[PATCH] D107449: [RISCV] Improve codegen for shuffles with LHS/RHS splats

Fraser Cormack via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 6 02:03:37 PDT 2021


frasercrmck marked 2 inline comments as done.
frasercrmck 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)
----------------
craig.topper wrote:
> 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.
Thanks for the assurance, that's much nicer!


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