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

Fraser Cormack via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 5 09:12:47 PDT 2021


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:
> 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?


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