[X86] Don't elide argument copies for scalarized vectors (PR63475)
authorNikita Popov <npopov@redhat.com>
Thu, 29 Jun 2023 13:37:09 +0000 (15:37 +0200)
committerNikita Popov <npopov@redhat.com>
Thu, 13 Jul 2023 12:49:48 +0000 (14:49 +0200)
commit7025ac81f05c90e0beee67755d81f5be7c508e52
tree6af0366897b45432298b8d58da2c1c1f4fdde823
parentf78a06ef111d619d160a92d1fd7553337a1921a1
[X86] Don't elide argument copies for scalarized vectors (PR63475)

When eliding argument copies, the memory layout between a plain
store of the type and the layout of the argument lowering on the
stack must match. For multi-part argument lowerings, this is not
necessarily the case.

The code already tried to prevent this optimization for "scalarized
and extended" vectors, but the check for "extends" was incomplete.
While a scalarized vector of i32s stores i32 values on the stack,
these are stored in 8 byte stack slots (on x86_64), so effectively
have padding.

Rather than trying to add more special cases to handle this (which
is not straightforward), I'm going in the other direction and
exclude scalarized vectors from this optimization entirely. This
seems like a rare case that is not worth the hassle -- the complete
lack of test coverage is not reassuring either.

Fixes https://github.com/llvm/llvm-project/issues/63475.

Differential Revision: https://reviews.llvm.org/D154078
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/pr63475.ll