[llvm] [SLP][REVEC] Fix CommonMask is transformed into vector form but used outside finalize. (PR #120952)

Han-Kuan Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 25 01:37:37 PST 2024


HanKuanChen wrote:

Take the following code as an example.
```
    if (Action) {
      Value *Vec = InVectors.front();
      if (InVectors.size() == 2) {
        Vec = createShuffle(Vec, InVectors.back(), CommonMask);
        InVectors.pop_back();
      } else {
        Vec = createShuffle(Vec, nullptr, CommonMask);
      }
      for (unsigned Idx = 0, Sz = CommonMask.size(); Idx < Sz; ++Idx)
        if (CommonMask[Idx] != PoisonMaskElem)
          CommonMask[Idx] = Idx;
      assert(VF > 0 &&
             "Expected vector length for the final value before action.");
      unsigned VecVF = cast<FixedVectorType>(Vec->getType())->getNumElements();
      if (VecVF < VF) {
        SmallVector<int> ResizeMask(VF, PoisonMaskElem);
        std::iota(ResizeMask.begin(), std::next(ResizeMask.begin(), VecVF), 0);
        Vec = createShuffle(Vec, nullptr, ResizeMask);
      }
      Action(Vec, CommonMask);
      InVectors.front() = Vec;
    }
```
How do you know `<4 x Ty>` from `unsigned VecVF = cast<FixedVectorType>(Vec->getType())->getNumElements();` is two `<2 x Ty>` (so VF is 2) instead of four `Ty` (so VF is 4)?

https://github.com/llvm/llvm-project/pull/120952


More information about the llvm-commits mailing list