This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Generate smov in place of sext(fmov(...))
ClosedPublic

Authored by NickGuy on Aug 24 2021, 7:47 AM.

Details

Summary

A single smov instruction is capable of moving from a vector register while performing the sign-extend during said move, rather than each step being performed by separate instructions.

Diff Detail

Event Timeline

NickGuy created this revision.Aug 24 2021, 7:47 AM
NickGuy requested review of this revision.Aug 24 2021, 7:47 AM
paulwalker-arm added inline comments.Aug 24 2021, 9:19 AM
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
2509–2512

These should be using VectorIndexB.

2514–2517

These should only use VectorIndexH.

2519–2520

This should be using VectorIndexS.

llvm/test/CodeGen/AArch64/aarch64-smov-gen.ll
6–18

Please simplify the tests. For example

target triple = "aarch64-unknown-linux-gnu"

define i32 @extract_s8(<vscale x 16 x i8> %a) #0 {
  %elt = extractelement <vscale x 16 x i8> %a, i32 15
  %conv = sext i8 %elt to i32
  ret i32 %conv
}

attributes #0 = { "target-features"="+sve" }

Should be enough to test the new patterns.

Given the VectorIndex# issues above I think it's worth having tests for out-of-range indices as well. I guess testing extract element VF-1 and extract element VF will cover the good and less good cases.

NickGuy updated this revision to Diff 368597.Aug 25 2021, 3:22 AM
NickGuy marked 4 inline comments as done.

Addressed comments, adding additional test cases that cover cases with out-of-range indices.

paulwalker-arm accepted this revision.Aug 25 2021, 5:28 AM

The out-of-range tests show that with a few more patterns we can do better, but given they're not the common case I guess they can wait.

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
2509–2520

Can you move these patterns up a couple of blocks to be just after the UMOV variants as that's the block they relate to.

This revision is now accepted and ready to land.Aug 25 2021, 5:28 AM
This revision was automatically updated to reflect the committed changes.