This is an archive of the discontinued LLVM Phabricator instance.

[SVE] Fix VLS FMA generation at CodeGenOpt::Aggressive
ClosedPublic

Authored by cameron.mcinally on Oct 26 2021, 9:41 AM.

Details

Summary

@paulwalker-arm Here is a hastily prepared patch of the problem we discussed earlier today. I'm a little out of the VLS loop, so perhaps there is a better way to handle this...

For VLS lowering, the DAGCombiner is not matching fixed width vector FMAs at CodeGenOpt::Aggressive, since the fixed width FMA matching at CodeGenOpt::Aggressive is done in the MachineCombiner. However, when the MachineCombiner runs, we have already lowered the fixed width vectors to scalable vectors, so FMAs are not generated at all. This patch corrects that by allowing the DAGCombiner to match FMAs if we are using VLS.

Diff Detail

Event Timeline

cameron.mcinally requested review of this revision.Oct 26 2021, 9:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2021, 9:41 AM
madhur13490 added inline comments.
llvm/test/CodeGen/AArch64/sve-fixed-length-fp-fma.ll
82

Do we want to have a test where %a and %b are globals?

llvm/test/CodeGen/AArch64/sve-fixed-length-fp-fma.ll
82

I haven't looked at VLS tests in a while, so that may have changed, but IINM this is the standard format for those tests. See sve-fixed-length*.ll for reference.

Fix clang-format warning and add the missing '+' to "+sve".

Thanks @cameron.mcinally, I see what you mean now.

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
12688

Does !useSVEForFixedLengthVectorVT(VT) also work? That way we maintain existing behaviour for NEON sized vectors.

llvm/test/CodeGen/AArch64/sve-fixed-length-fp-fma.ll
17

Given this is a DAG combine I don't see much value in testing all combinations of -aarch64-sve-vector-bits-min so perhaps just have a single RUN line using the maximum value. That way you don't need VBYTES and can use update_llc_test_checks.py to generate the CHECK lines.

Updated Diff for @paulwalker-arm's reviews...

paulwalker-arm accepted this revision.Nov 1 2021, 6:03 AM

Perhaps worth adding matching half/fp16 tests to sve-fixed-length-fp-fma.ll but otherwise looks good.

This revision is now accepted and ready to land.Nov 1 2021, 6:03 AM
cameron.mcinally edited the summary of this revision. (Show Details)Nov 1 2021, 8:47 AM

Perhaps worth adding matching half/fp16 tests to sve-fixed-length-fp-fma.ll but otherwise looks good.

Added and submitted. Will address any post-commit reviews as needed.