This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE] Add API for conversion between SVE predicate pattern and element count. NFC
ClosedPublic

Authored by junparser on Aug 25 2021, 8:07 AM.

Details

Summary

This patch solely moves convert operation between SVE predicate pattern
and element count into two small functions. It's pre-commit patch for optimize
pture with known sve register width.

Diff Detail

Event Timeline

junparser created this revision.Aug 25 2021, 8:07 AM
junparser requested review of this revision.Aug 25 2021, 8:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2021, 8:07 AM
david-arm added inline comments.Aug 25 2021, 8:52 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
18027

You're removing the unreachable here. Perhaps it's worth adding an assert:

assert(PgPattern && "Unexpected element count for SVE predicate")
18058

Maybe we should leave this TODO here as I think it still applies?

llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
457

I think that using both inline and static keywords here causes clang-tidy to think it's unused. Can you just use the inline keyword here instead?

457

I think this breaks case style rules - perhaps this should be named something like getNumElementsFromSVEPredPattern?

492

Same comments as above.

paulwalker-arm added inline comments.Aug 25 2021, 8:57 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
18031

This'll need to be validated as with the original code.

18058–18060

I think this is an important comment that should remain within getPredicateForFixedLengthVector. See comment on D108706.

llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
457

I'm not a fan of the names of these functions as ElementCount has an existing meaning within LLVM and these function are not really honouring it. Perhaps getSVEPredicatePatternAsFixedLength/getSVEPredicatePatternForFixedLength? Or something of similar ilk.

Can you add a function comment that makes it explicit that zero is returned for the case where no translation is possible.

470–471

Is there an LLVM coding style policy here? For example is setting MinNumElts and breaking preferred over just using return.

498–499

Same "return" comment as above.

junparser added inline comments.Aug 25 2021, 7:12 PM
llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
470–471

I checked https://llvm.org/docs/CodingStandards.html, There is no rules for switch cases.

junparser updated this revision to Diff 368794.Aug 25 2021, 8:02 PM

Address comment.

david-arm added inline comments.Aug 26 2021, 1:08 AM
llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
470–471

OK, I guess that's fine, but returning without breaks maybe does look nicer and more compact (it kills off 8 lines of code)? It's also more consistent with the default case that does return early.

i.e.

switch (Pattern) {
default:
  return 0;
case AArch64SVEPredPattern::vl1:
...
  return Pattern;
...
}

I don't feel too strongly about it though. :)

junparser updated this revision to Diff 368831.Aug 26 2021, 1:44 AM

Address comment.

paulwalker-arm accepted this revision.Aug 26 2021, 3:33 AM
paulwalker-arm added inline comments.
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
655

As a bit of extra tidying perhaps merge this MinNumElts > NumElts with the new if (!MinNumElts).

This revision is now accepted and ready to land.Aug 26 2021, 3:33 AM