[PATCH] D80235: [SVE] Eliminate calls to VectorType::getNumElements from BasicTTIImpl.h

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 20 09:50:34 PDT 2020


ctetreau marked an inline comment as done.
ctetreau added a comment.

In D80235#2045995 <https://reviews.llvm.org/D80235#2045995>, @samparker wrote:

> There's quite a few casts of ShuffleVectorInst types and I was wondering whether this class will also be ported to the Fixed type?


It's possible to do shufflevector on scalable vectors if you jump through some hoops. For instance, you can make a splat if you insertelement the splat value into the zeroeth element of undef, then shufflevector the result of that with undef and zeroinitializer as the mask. There's an RFC to extend shufflevector on scalable vectors: http://lists.llvm.org/pipermail/llvm-dev/2020-January/138762.html. It hasn't been updated in a while, but it's not dead, just dormant.

For now, the plan is to assume all usages of getNumElements are in fact fixed-width operations. If the assumption is incorrect, LLVM will fail to cast right away, rather than miscompile or blow up 10 functions down the line.



================
Comment at: llvm/include/llvm/CodeGen/BasicTTIImpl.h:1128
+          ScalarizationCost += getScalarizationOverhead(
+              cast<FixedVectorType>(RetTy), true, false);
         ScalarizationCost += getOperandsScalarizationOverhead(Args, VF);
----------------
samparker wrote:
> I'm assuming this cast isn't necessary?
It actually is. RetTy is a Type * and getScalarizationOverhead calls FixedVectorType::getNumElements().

It looks like the type returned by ICA.getReturnType() might be void, so we can't assign it to a FixedVectorType *.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80235





More information about the llvm-commits mailing list