This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE] Implement lowering for SIGN_EXTEND etc. of SVE predicates.
ClosedPublic

Authored by efriedma on Apr 30 2020, 11:51 AM.

Details

Summary

Now using patterns, since there's a single-instruction lowering. (We could convert to VSELECT and pattern-match that, but there doesn't seem to be much point.)

I think this might be the first instruction to use nested multiclasses this way? It seems like a good way to reduce duplication between different integer widths. Let me know if it seems like an improvement.

Also, while I'm here, fix the return type of SETCC so we don't try to merge a sign-extend with a SETCC.

Diff Detail

Event Timeline

efriedma created this revision.Apr 30 2020, 11:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 30 2020, 11:52 AM
sdesmalen added inline comments.May 1 2020, 9:33 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
8956

Not sure if you were aware, but we can match these extends directly to use a predicated cpy/mov immediate:

// per-element any extend
def : Pat<(nxv16i8 (anyext (nxv16i1 PPR:$Ps1))),
          (CPY_ZPzI_B PPR:$Ps1, 0x1, 0)>;
...

// per-element sign extend
def : Pat<(nxv16i8 (sext (nxv16i1 PPR:$Ps1))),
          (CPY_ZPzI_B PPR:$Ps1, -1, 0)>;
...

// per-element zero extend
def : Pat<(nxv16i8 (zext (nxv16i1 PPR:$Ps1))),
          (CPY_ZPzI_B PPR:$Ps1, 0x1, 0)>;
...

(For the full set of patterns, see D71712)

efriedma updated this revision to Diff 261607.May 1 2020, 7:53 PM
efriedma edited the summary of this revision. (Show Details)

Updated to use patterns; thanks for the pointer.

efriedma updated this revision to Diff 261608.May 1 2020, 8:00 PM

I accidentally broke the last version; should be working now.

fpetrogalli added inline comments.May 1 2020, 8:25 PM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
998–999

I am not sure if it is possible, but is this change tested anywhere?

efriedma marked an inline comment as done.May 1 2020, 9:30 PM
efriedma added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
998–999

sve-fcmp.ll fails without this change.

sdesmalen accepted this revision.May 5 2020, 7:53 AM

LGTM!

This revision is now accepted and ready to land.May 5 2020, 7:53 AM
fpetrogalli accepted this revision.May 5 2020, 9:36 AM
fpetrogalli marked an inline comment as done.

LGTM!

Thank you

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
998–999

Thanks for explaining!

This revision was automatically updated to reflect the committed changes.