This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Fix Crashes in fp16/bf16 Inline Asm
ClosedPublic

Authored by lenary on Apr 6 2023, 8:31 AM.

Details

Summary

We were still seeing occasional crashes with inline assembly blocks
using fp16/bf16 after my previous patches:

It turns out:

  • The original two commits were wrong, and we should have always been choosing the SPR register class, not the HPR register class, so that LLVM's SelectionDAGBuilder correctly did the right splits/joins.
  • The splitValueIntoRegisterParts/joinRegisterPartsIntoValue changes from rG20b2d11896d9 are still correct, even though they sometimes result in inefficient codegen of casts between fp16/bf16 and i32/f32 (which is visible in these tests).

This patch fixes crashes in getCopyToParts and when trying to select
(bf16 (bitconvert (fp16 ...))) dags when Neon is enabled.

This patch also adds support for passing fp16/bf16 values using the 'x'
constraint that is LLVM-specific. This should broadly match how we pass
with 't' and 'w', but with a different set of valid S registers.

Diff Detail

Event Timeline

lenary created this revision.Apr 6 2023, 8:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2023, 8:31 AM
lenary requested review of this revision.Apr 6 2023, 8:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2023, 8:31 AM
lenary retitled this revision from [ARM] Fix Crashes in fp16/bf16 Inlne Asm to [ARM] Fix Crashes in fp16/bf16 Inline Asm.Apr 6 2023, 8:33 AM
lenary added reviewers: tmatheson, olista01, stuij.
olista01 added inline comments.Apr 11 2023, 5:08 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
20357

Should f16 and bf16 be allowed for the x constraint too?

This revision is now accepted and ready to land.Apr 11 2023, 5:17 AM
lenary added inline comments.Apr 12 2023, 3:31 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
20357

I'm not sure, so I've asked where the x constraint came from. It was introduced in https://reviews.llvm.org/D65863 but x is not documented on https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html . The original impetus behind this work was bringing us inline with GCC for t: https://github.com/llvm/llvm-project/issues/57753 .

lenary updated this revision to Diff 512863.Apr 12 2023, 8:59 AM
lenary edited the summary of this revision. (Show Details)
lenary added inline comments.Apr 12 2023, 8:59 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
20357

Yes, they should, because they're in the langref: https://www.llvm.org/docs/LangRef.html#supported-constraint-code-list

Will do this change today.

lenary marked an inline comment as done.Apr 12 2023, 8:59 AM
lenary added inline comments.Apr 12 2023, 9:07 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
20357

To clarify, because I submitted in the wrong order: this is done.

lenary updated this revision to Diff 513163.Apr 13 2023, 3:56 AM