[PATCH] D119469: [AArch64] Turn truncating buildvectors into truncates

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 10 12:10:48 PST 2022


dmgreen created this revision.
dmgreen added reviewers: samtebbs, fhahn, sdesmalen, david-arm.
Herald added subscribers: hiraditya, kristof.beyls.
dmgreen requested review of this revision.
Herald added a project: LLVM.

When lowering large v16f32->v16i8 fp_to_si_sat, the fp_to_si_sat node it split several times, creating an illegal v4i8 concat that gets expanded into a BUILD_VECTOR. After some combining and other legalisation, it ends up the a buildvector that extracts from 4 vectors, looking like `BUILDVECTOR(a0,a1,a2,a3,b0,b1,b2,b3,c0,c1,c2,c3,d0,d1,d2,d3)`. That is really an v16i32->v16i8 truncate in disguise. This adds a ReconstructTruncateFromBuildVector method to detect the pattern, converting it back into the legal `concat(trunc(concat(trunc(a), trunc(b))), trunc(concat(trunc(c), trunc(d))))` tree. The extracted nodes could also be v4i16, in which case the truncates are not needed. All those truncates and concats then become uzip1's, which it much better than expanding by moving vector lanes around.

Found when looking at D96522 <https://reviews.llvm.org/D96522>.


https://reviews.llvm.org/D119469

Files:
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/fptosi-sat-vector.ll
  llvm/test/CodeGen/AArch64/fptoui-sat-vector.ll
  llvm/test/CodeGen/AArch64/neon-extracttruncate.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119469.407629.patch
Type: text/x-patch
Size: 11995 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220210/035bb73d/attachment.bin>


More information about the llvm-commits mailing list