[PATCH] D124284: [SLP]Try partial store vectorization if supported by target.

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 30 09:00:49 PDT 2022


dmgreen added a comment.

Thanks for the update, this looks better to me. The perf results I have were looking OK too, except for one fp16 case where it was choosing to use v2f16 vectorization. It could be OK, it's essentially trading unrolling vs vectorizing and one isn't obviously better or worse than the other. But small vectorization factors can be difficult at times.

I think the problem is that getOperationAction will get the data from these OpActions, which will all be initialize to 0 (=Legal) and targets do not usually overrides that for illegal types:
https://github.com/llvm/llvm-project/blob/a9d68a5524dea113cace5983697786599cbdce9a/llvm/lib/CodeGen/TargetLoweringBase.cpp#L733

So it can pick up "Legal" stores just because the default initialization and the target has never had to set them to anything else in the past. There are TruncStoreActions that should be set though. What do you think of using something like this, based on whether there is a legal trunk store?

  unsigned getStoreMinimumVF(unsigned VF, Type *ScalarTy) const {
    auto &&IsSupportedByTarget = [this, ScalarTy](unsigned VF) {
      auto *SrcTy = FixedVectorType::get(ScalarTy, VF / 2);
      EVT VT = getTLI()->getValueType(DL, SrcTy);
      TargetLowering::LegalizeAction LA =
          getTLI()->getOperationAction(ISD::STORE, VT);
      if (getTLI()->isTypeLegal(VT) &&
          (LA == TargetLowering::Legal || LA == TargetLowering::Custom))
        return true;
  
      auto LT = getTLI()->getTypeLegalizationCost(DL, SrcTy);
      LA = getTLI()->getTruncStoreAction(LT.second, VT);
      return LA == TargetLowering::Legal || LA == TargetLowering::Custom;
    };
    while (VF > 2 && IsSupportedByTarget(VF))
      VF /= 2;
    return VF;
  }

Would that work for the cases you are interested in? The target can override it in any case, so at least it is controllable. But if that works for your use-cases it should hopefully match the target lowering a little better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124284



More information about the llvm-commits mailing list