[SelectionDAG] Fix getVectorSubVecPointer for scalable subvectors.
authorSander de Smalen <sander.desmalen@arm.com>
Tue, 12 Oct 2021 11:37:42 +0000 (12:37 +0100)
committerSander de Smalen <sander.desmalen@arm.com>
Wed, 20 Oct 2021 12:55:24 +0000 (13:55 +0100)
commitbe6c8dc765c32a79c0c9b0e6720e3b22d226e478
tree008660e5d0fba0e19d88f4adc1d381acea0e5757
parent5a8ad80b6fa5cbad58b78384f534b78fca863e7f
[SelectionDAG] Fix getVectorSubVecPointer for scalable subvectors.

When inserting a scalable subvector into a scalable vector through
the stack, the index to store to needs to be scaled by vscale.
Before this patch, that didn't yet happen, so it would generate the
wrong offset, thus storing a subvector to the incorrect address
and overwriting the wrong lanes.

For some insert:
  nxv8f16 insert_subvector(nxv8f16 %vec, nxv2f16 %subvec, i64 2)

The offset was not scaled by vscale:
  orr     x8, x8, #0x4
  st1h    { z0.h }, p0, [sp]
  st1h    { z1.d }, p1, [x8]
  ld1h    { z0.h }, p0/z, [sp]

And is changed to:
  mov x8, sp
  st1h { z0.h }, p0, [sp]
  st1h { z1.d }, p1, [x8, #1, mul vl]
  ld1h { z0.h }, p0/z, [sp]

Differential Revision: https://reviews.llvm.org/D111633
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/AArch64/sve-insert-vector.ll