[PATCH] D151221: [RISCV] Scalarize constant stores of fixed vectors up to 32 bits

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 02:34:29 PDT 2023


luke added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:12190
     // initialize any power-of-two size up to XLen bits.
     if (DCI.isBeforeLegalize() && IsScalarizable &&
         ISD::isBuildVectorAllZeros(Val.getNode())) {
----------------
reames wrote:
> Isn't this case now fully covered by the one you added?  I think you can delete this.  
> 
> Ah, I see the problem.  Rather than checking that MemVT is less than 32 bits, you can check that the splat constant isUint<32>.  
> 
> Or if you want, you can directly check materialization cost < 2 using RISCVMatInt.cpp/h
Good idea about checking the constant, will do that. I kept in the zeroes case because `isConstantSplat` claims to not work on anything smaller than i8, and there are some test cases for i1s that we want this to work on annoyingly.

I agree that it's weird that there's not a better interface for this. Elsewhere in RISCVISelLowering.cpp its just done by hand like:

```
    unsigned EltIdx = 0;
    uint64_t EltMask = maskTrailingOnes<uint64_t>(EltBitSize);
    uint64_t SplatValue = 0;
    // Construct the amalgamated value which can be splatted as this larger
    // vector type.
    for (const auto &SeqV : Sequence) {
      if (!SeqV.isUndef())
        SplatValue |= ((cast<ConstantSDNode>(SeqV)->getZExtValue() & EltMask)
                       << (EltIdx * EltBitSize));
      EltIdx++;
    }
```

It might actually be easier to just reuse this instead.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151221/new/

https://reviews.llvm.org/D151221



More information about the llvm-commits mailing list