This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Add tablegen patterns for faddp of two extracts
ClosedPublic

Authored by dmgreen on Jun 6 2023, 12:59 AM.

Details

Summary

This adds some simple tablegen patterns for converting faddp v2f32 extractlow(Rn), v2f32 extracthigh(Rn) to faddp v4f32 Rn, v4f32 Rn using the q variants of the instructions, avoiding the extra ext needed to extract the high lanes. Only the bottom lanes of the new faddp are used, the second Rn operand is used as a placeholder. It uses Rn to prevent any false dependencies, but could equally by undef.

Diff Detail

Event Timeline

dmgreen created this revision.Jun 6 2023, 12:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 6 2023, 12:59 AM
dmgreen requested review of this revision.Jun 6 2023, 12:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 6 2023, 12:59 AM
david-arm added inline comments.
llvm/lib/Target/AArch64/AArch64InstrInfo.td
8522

Hi @dmgreen, apologies for the drive-by comment, but I wonder if this needs a return type from extract_subvector in case it attempts to match the wrong subvector type? For example, in theory this may attempt to match

AArch64faddp (v1i32 extract_subvector (v4f32 FPR128:$Rn), (i64 0)),
                        (v1i32 extract_subvector (v4f32 FPR128:$Rn), (i64 2)))

as well as the pattern I presume you actually want to match, which is

AArch64faddp (v2i32 extract_subvector (v4f32 FPR128:$Rn), (i64 0)),
                        (v2i32 extract_subvector (v4f32 FPR128:$Rn), (i64 2)))

?

dmgreen added inline comments.Jun 13 2023, 8:49 AM
llvm/lib/Target/AArch64/AArch64InstrInfo.td
8522

Sorry I apparently missed this. v1f32 is neither a legal type, nor a valid input to AArch64faddp. I'm pretty sure that the only type this can be would be a v2f32. I can add them if you think it's better to be careful, but I don't believe it is necessary. Let me know if you think otherwise.

david-arm accepted this revision.Jun 16 2023, 8:05 AM

LGTM!

llvm/lib/Target/AArch64/AArch64InstrInfo.td
8522

OK I see. Fair enough!

It also took me a while to understand that you are essentially transforming a FADDPv2f32 into a low(FADDPv4f32), which I see now. Perhaps having an explicit v2f32 type in here makes it more readable? But I'm not going to hold up the patch for it. :)

This revision is now accepted and ready to land.Jun 16 2023, 8:05 AM
This revision was landed with ongoing or failed builds.Jun 18 2023, 11:48 PM
This revision was automatically updated to reflect the committed changes.
dmgreen added inline comments.Jun 18 2023, 11:51 PM
llvm/lib/Target/AArch64/AArch64InstrInfo.td
8522

Sounds good.