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

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 30 09:25:23 PDT 2022


ABataev added a comment.

In D124284#3484061 <https://reviews.llvm.org/D124284#3484061>, @dmgreen wrote:

> 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.

I tried something similar already, it won't work. Plus, trunc store is not the case we're looking at here, it is different. This function just says to vectorizer that it might be worth trying this vector factor. The cost model should later inform that it is not profitable. If something is not correct in the TTI, it should be fixed in TTI.


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