DAG: Avoid stack lowering if bitcast has an illegal vector result type
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 13 Jan 2023 21:15:52 +0000 (16:15 -0500)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Sun, 15 Jan 2023 17:37:14 +0000 (12:37 -0500)
commitab6b48b7116d118131e7ef459e4d234b4366564f
treee9f333224718a5d44de886b8f430e49e77768739
parent94461822c75d5080bf648f86552f7a59b76905c9
DAG: Avoid stack lowering if bitcast has an illegal vector result type

A bitcast of <10 x i32> to <5 x i64> was ending up on the
stack. Instead of doing that, handle the case where the new type
doesn't evenly divide but the elements do. Extract the individual
elements and pad with undef.

Avoids stack usage for bitcasts involving <5 x i64>. In some of these
cases, later optimizations actually eliminated the stack objects but
left behind the unused temporary stack object to final emission.

Fixes: SWDEV-377548
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.ll
llvm/test/CodeGen/AMDGPU/copy-illegal-type.ll
llvm/test/CodeGen/AMDGPU/copy-to-reg-scc-clobber.ll
llvm/test/CodeGen/AMDGPU/flat_atomics_i64.ll
llvm/test/CodeGen/AMDGPU/global_atomics_i64.ll
llvm/test/CodeGen/AMDGPU/insert_vector_dynelt.ll
llvm/test/CodeGen/AMDGPU/select.f16.ll
llvm/test/CodeGen/AMDGPU/v_madak_f16.ll
llvm/test/CodeGen/AMDGPU/vector_shuffle.packed.ll