[WebAssembly] Fix crash when selecting 64 bit lane extract operand
authorLuke Lau <luke@igalia.com>
Fri, 16 Dec 2022 12:20:26 +0000 (12:20 +0000)
committerLuke Lau <luke@igalia.com>
Mon, 19 Dec 2022 10:37:19 +0000 (10:37 +0000)
commit8ef5da701003649d3d31c3b3aa299fba30e4a4b3
tree32a0cc7055438c1b9002341ff7fbcc63a45bee59
parent45067d1a74c8409328332c0d60cfc71601bfc846
[WebAssembly] Fix crash when selecting 64 bit lane extract operand

The tablegen patterns on vector_extract only match i32 constants, but
on wasm64 these come in as i64 constants. In certain situations this
would cause crashes whenever it couldn't select an extract_vector_elt
instruction.
Rather than add duplicate patterns for every instruction, this just
canonicalizes the constant to be i32 when lowering.
Fixes https://github.com/llvm/llvm-project/issues/57577

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