This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] match splat of bitcasted extract subvector to DUPLANE
ClosedPublic

Authored by spatel on Dec 18 2019, 12:49 PM.

Details

Summary

This is another potential regression exposed by D63815.

Here we peek through a bitcast to find an extract subvector and scale the splat offset based on that:
splat (bitcast (extract X, C)), LaneC --> duplane (bitcast X), LaneC'

Diff Detail

Event Timeline

spatel created this revision.Dec 18 2019, 12:49 PM
efriedma added inline comments.Dec 18 2019, 1:30 PM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
7045

Can you fix the comments here, so each of these transforms has its own comment briefly explaining what it does?

V1.getOperand(0).getScalarValueSizeInBits() % VTEltBitWidth == 0 seems overly restrictive. I guess you have to enforce that the EXTRACT_SUBVECTOR index is appropriately aligned, but it would be okay to allow, for example, <16 x i8> with index 8. Maybe translate the EXTRACT_SUBVECTOR index to a byte offset, then divide by the element size of the result? That should also make the logic a little easier to follow.

spatel updated this revision to Diff 234879.Dec 20 2019, 6:29 AM
spatel marked an inline comment as done.

Patch updated:

  1. Enhanced to allow narrow element -> wide element bitcasts. (tests added with rG59811f454df0)
  2. Restructured and added code/test comments (hopefully makes it easier to read).
efriedma added inline comments.Dec 20 2019, 11:57 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
7084

Can we compute SrcVecNumElts as Extract.getOperand(0).getValueType().getSizeInBits()/CastedEltBitWidth, or something like that?

spatel marked 2 inline comments as done.Dec 20 2019, 1:02 PM
spatel added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
7084

Ah, yes - that will simplify things. I was hung up on scaling that value, but it's unnecessary.

spatel updated this revision to Diff 234958.Dec 20 2019, 1:04 PM
spatel marked an inline comment as done.

Patch updated:
Simplify code for calculating the casted source vector type.

This revision is now accepted and ready to land.Dec 20 2019, 1:18 PM
This revision was automatically updated to reflect the committed changes.