This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE]Support for SVE instrinsic in AArch64TargetTransformInfo
AbandonedPublic

Authored by duan.db on Nov 23 2021, 11:53 PM.

Details

Summary

Due to the imperfect support of AArch64TargetTransformInfo for SVE Intrinsic, the loop-reduce pass did not obtain the correct information. It will assign the wrong type to the LSRUser, and the generated assembly appears redundant.

This patch is simple support for AArch64TargetTransformInfo. Please have a look and give some advance.
If it's OK, I will go on with other SVE intrinsic support.

Diff Detail

Event Timeline

duan.db created this revision.Nov 23 2021, 11:53 PM
duan.db requested review of this revision.Nov 23 2021, 11:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2021, 11:53 PM

The change itself seems sensible to me. Just left a few comments on the test.

llvm/test/Transforms/LoopStrengthReduce/AArch64/getTgtMemIntrinsic1.ll
1 ↗(On Diff #389401)

This RUN line doesn't use FileCheck to check the output?

4 ↗(On Diff #389401)

Can you add some extra CHECK lines, and move the CHECK lines to below define void @example01_sve? It's not clear from the CHECK line that loop-reduce is doing the correct thing.

Some other nits:

  • Could you please add a comment with context about what this test is supposed to test?
  • Maybe remove the name @example01_sve to something more descriptive?
  • Can you rename the file to something more descriptive, e.g. sve-load-store-intrinsics.ll ?
duan.db updated this revision to Diff 390363.Nov 29 2021, 7:38 AM

@sdesmalen Thank you for your review, and so sorry for the delay. I have modified the test case according to your valuable suggestions. This test case checks whether loop-reduce can be assigned the correct type(i.e. Address Type)to the SVE load and store intrinsic. If so, SVE.load will reuse the original induction variable, and compilation is more reasonable.
Any other suggestions about the code?

Ping. Hi, everyone. Do you agree to commit?

Sorry I missed that you updated the patch.

llvm/test/Transforms/LoopStrengthReduce/AArch64/sve-load-store-intrinsics.ll
7

nit: please also add:

CHECK-LABEL: @sve-load-store-intrinsics
36

Can you duplicate this test, but using ld2 and st2, so that we have at least one test for the structured load/stores?

My understand of how MemIntrinsicInfo is used is not great so please forgive some potentially naive questions.

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
2070

How literal is the description of this property in TargetTransformInfo.h. Specifically it says:

/// If this is non-null, then analysis/optimization passes can assume that
/// this intrinsic is functionally equivalent to a load/store from this
/// pointer.

However, these are predicated loads and stores and thus they take an extra operand that controls when/if memory is accessed.

Looking at EarlyCSE I can see there exists support for the common masked_load and masked_store intrinsics, where masks are considered (see isNonTargetIntrinsicMatch), but I cannot see such for target intrinsics.

This makes me believe we cannot just populate MemIntrinsicInfo for the SVE intrinsics because the data will be incomplete and potentially cause things like EarlyCSE to do the wrong thing.

2097–2104

Is it safe to not set MatchingId here? My assumption is that means all SVE load/strore intrinsics will have the same Id and thus code like in EarlyCSE.cpp that compares the MatchingId of two instructions may not get whatever guarantee they're trying to obtain.

I forgot to mention this before but we now lower Intrinsic::aarch64_sve_ld1 and Intrinsic::aarch64_sve_st1 to either load/store instructions or masked_load/masked_store intrinsics. So perhaps the original need for this patch has gone away?

duan.db abandoned this revision.Dec 23 2021, 7:20 PM