This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Optimize SVE bitcasts of unpacked types.
ClosedPublic

Authored by efriedma on Jun 18 2021, 3:05 PM.

Details

Summary

Target-independent code only knows how to spill to the stack; instead, use AArch64ISD::REINTERPRET_CAST.

Diff Detail

Event Timeline

efriedma created this revision.Jun 18 2021, 3:05 PM
efriedma requested review of this revision.Jun 18 2021, 3:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 18 2021, 3:05 PM
Matt added a subscriber: Matt.Jun 19 2021, 7:55 AM
paulwalker-arm added inline comments.Jun 21 2021, 4:27 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
3533–3535

You may as well just remove the "Cannot cast between unpacked scalable vector types" assert from getSVESafeBitCast. The original intent of the assert was to catch cases where getSVESafeBitCast wasn't needed because a single REINTERPRET_CAST could do the job. The assert is clearly too generic but at the same time I deliberately didn't add isel patterns for the unpacked-unpacked-fp cases[1], so I don't see a real benefit to tightening up the assert.

[1] I know this is not consistent with i1 handling.

llvm/test/CodeGen/AArch64/sve-bitcast.ll
460

Out of interest are the loads fundamental to these three tests?

efriedma added inline comments.Jun 21 2021, 10:29 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
3533–3535

Sure, will do.

llvm/test/CodeGen/AArch64/sve-bitcast.ll
460

When I was constructing the tests, I had to be careful to make sure we actually hit the codepath in question. In the simplest cases, the bitcast gets combined away.

Maybe it's not necessary for the final form these tests ended up with, though; I'll check.

efriedma updated this revision to Diff 353424.Jun 21 2021, 10:56 AM

Address review comments.

paulwalker-arm accepted this revision.Jun 22 2021, 3:26 AM
paulwalker-arm added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
3526

Up to you but perhaps worth pulling this out as it now has three uses.

16893

Can reuse Op here.

16895

Can reuse DL here.

This revision is now accepted and ready to land.Jun 22 2021, 3:26 AM
This revision was landed with ongoing or failed builds.Jul 1 2021, 3:37 PM
This revision was automatically updated to reflect the committed changes.