[PATCH] D113772: [Analysis] Fix getNumberOfParts to return 0 when the answer is unknown

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 12 06:57:46 PST 2021


david-arm created this revision.
david-arm added reviewers: sdesmalen, kmclaughlin, fhahn, simoll, peterwaller-arm.
Herald added subscribers: ctetreau, CarolineConcatto, hiraditya, kristof.beyls.
david-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When asking how many parts are required for a scalable vector type
there are occasions when it cannot be computed. For example, <vscale x 1 x i3>
is one such vector for AArch64+SVE because no matter how we promote the i3
type we never end up with a legal vector. In BasicTTImpl this means
getNumberOfParts attempts to dereference an invalid cost, which triggers
an assert. This patch changes the BasicTTImpl implementation of
getNumberOfParts to return 0 for such cases, since the definition of
getNumberOfParts in TargetTransformInfo.h states that we can use a
return value of 0 to represent an unknown answer.

Currently, LoopVectorize.cpp is the only place where we need to check for
0 as a return value, because all other instances will not currently
ask for the number of parts for <vscale x 1 x iX> types.

In addition, I have changed the target-independent interface for
getNumberOfParts to return 1 and assume there is a single register
that can fit the type. The loop vectoriser has lots of tests that are
target-independent and they relied upon the 0 value to mean the
answer is known and that we are not scalarising the vector.

I have added tests here that show we correctly return an invalid cost
for VF=vscale x 1 when the loop contains unusual types such as i7:

  Transforms/LoopVectorize/AArch64/sve-inductions-unusual-types.ll


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113772

Files:
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/AArch64/sve-inductions-unusual-types.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113772.386840.patch
Type: text/x-patch
Size: 5284 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211112/54914aac/attachment.bin>


More information about the llvm-commits mailing list