[WASM] Fix legalizer for LowerBUILD_VECTOR.
authorPeter Rong <PeterRong96@gmail.com>
Thu, 30 Mar 2023 08:44:24 +0000 (01:44 -0700)
committerPeter Rong <PeterRong96@gmail.com>
Fri, 31 Mar 2023 02:20:04 +0000 (19:20 -0700)
commit51a93828d782dae09f2dc69aae53f4e6dd1ca98a
treeeb5fc084957efa0b5403d06ae66607e5fb379c35
parent962484aeca0cc6779899c95d59597f7240ea94ea
[WASM] Fix legalizer for LowerBUILD_VECTOR.

Constants in BUILD_VECTOR may be down cast into a smaller value that fits LaneBits, i.e., the bit width of elements in the vector.
This cast didn't consider 2^N where it would be cast into -2^N, which still doesn't fit into LaneBits after casting.
This will cause an assertion in later legalization.

2^N should be cast into 0, and this patch reflects such behavior.
This patch also includes a test to reflect the fix.
This patch fixes [issue 61780](https://github.com/llvm/llvm-project/issues/61780)

Related patch: https://reviews.llvm.org/D108669

Reviewed By: tlively

Differential Revision: https://reviews.llvm.org/D147208
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/test/CodeGen/WebAssembly/simd-pr61780.ll [new file with mode: 0644]