This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Fix warnings in getPackedVectorTypeFromPredicateType
ClosedPublic

Authored by david-arm on May 27 2020, 2:28 AM.

Details

Summary

Use getVectorElementCount() instead of getVectorNumElements().
The code changed in this patch is covered by an existing test:

CodeGen/AArch64/sve-intrinsics-contiguous-prefetches.ll

Diff Detail

Event Timeline

david-arm created this revision.May 27 2020, 2:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2020, 2:28 AM
fpetrogalli requested changes to this revision.May 29 2020, 11:49 AM

HI @david-arm ,

I will not hold this patch if you disagree on the nit, but I think you should remove the tests as they seem to duplicate something that is already tested.

Ciao,

Francesco

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
4627–4630

NIT:

We could be explicit here on the PredVT that we want to use and swap the statements as follows:

if (PredVT != MVT::nxv16i1 && PredVT != MVT::nxv8i1 && ...)
  return EVT();

ElementCount EC = ...

I am also wondering whether we can remove at all the idea of using EC.Min in this code and just use TypeSize. Something like the following:

if (PredVT != MVT::nxv16i1 && PredVT != MVT::nxv8i1 && ...)
  return EVT();

// This could actually be a global in the AArch64 namespace, to be used as AArch64::SVEBits,
// I suspect it will be handy in other situations.
const auto SVEVecSize = TypeSize::Scalable(AArch64::SVEBitsPerBlock);

EVT MemVT = PredVT;
while (MemVT.getSizeInBits() < SVETySy)
  MemVT = MemVT.widenIntegerVectorElementType(Ctx);

return MemVT;

Seems like a good thing to get rid of the EC.Min here?

llvm/test/CodeGen/AArch64/sve-intrinsics-prfw.ll
1 ↗(On Diff #266459)

These are already tested here: https://github.com/llvm/llvm-project/blob/master/llvm/test/CodeGen/AArch64/sve-intrinsics-contiguous-prefetches.ll

Any reason for re-adding them in a separate file? Or am I missing something?

This revision now requires changes to proceed.May 29 2020, 11:49 AM
david-arm marked an inline comment as done.May 31 2020, 11:20 PM
david-arm added inline comments.
llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
4627–4630

I think changing your first suggestion for checking the PredVT makes sense, however I don't think we should be afraid of using EC.Min here for calculations. However, I think your second suggestion is inefficient, since we are already in the AArch64 backend and we know exactly how to deal with scalable vectors. I believe calculating (SVEBitsPerBlock / EC.Min) is the right thing to do here - we know at this point EC is for a legal type, since we've already discarded illegal types.

david-arm updated this revision to Diff 267552.Jun 1 2020, 12:08 AM
david-arm edited the summary of this revision. (Show Details)
david-arm marked 2 inline comments as done.Jun 1 2020, 12:09 AM
fpetrogalli accepted this revision.Jun 2 2020, 11:22 AM

LGTM, thank for the explanation.

Francesco

This revision is now accepted and ready to land.Jun 2 2020, 11:22 AM
This revision was automatically updated to reflect the committed changes.