[ARM] Add FP16 vector insert/extract patterns
authorMikhail Maltsev <mikhail.maltsev@arm.com>
Tue, 4 Jun 2019 09:39:55 +0000 (09:39 +0000)
committerMikhail Maltsev <mikhail.maltsev@arm.com>
Tue, 4 Jun 2019 09:39:55 +0000 (09:39 +0000)
commit08da01b496481ea079b2e213f6e67ef1fd1c6f29
treeace216a64e07609af5e7c1be53652b5d77ddbe15
parent4ef0f82b71dedeb11d2ff40c6a68ac2737f07f59
[ARM] Add FP16 vector insert/extract patterns

This change adds two FP16 extraction and two insertion patterns
(one per possible vector length).
Extractions are handled by copying a Q/D register into one of VFP2
class registers, where single FP32 sub-registers can be accessed. Then
the extraction of even lanes are simple sub-register extractions
(because we don't care about the top parts of registers for FP16
operations). Odd lanes need an additional VMOVX instruction.

Unfortunately, insertions cannot be handled in the same way, because:
* There is no instruction to insert FP16 into an even lane (VINS only
  works with odd lanes)
* The patterns for odd lanes will have a form of a DAG (not a tree),
  and will not be implementable in pure tablegen

Because of this insertions are handled in the same way as 16-bit
integer insertions (with conversions between FP registers and GPRs
using VMOVHR instructions).

Without these patterns the ARM backend would sometimes fail during
instruction selection.

This patch also adds patterns which combine:
* an FP16 element extraction and a store into a single VST1
  instruction
* an FP16 load and insertion into a single VLD1 instruction

Differential Revision: https://reviews.llvm.org/D62651

llvm-svn: 362482
llvm/lib/Target/ARM/ARMInstrNEON.td
llvm/test/CodeGen/ARM/fp16-insert-extract.ll [new file with mode: 0644]
llvm/test/CodeGen/ARM/fp16-vldlane-vstlane.ll [new file with mode: 0644]