Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WASM] Cannot select BUILD_VECTOR when enabling SIMD128 #63817

Closed
HazyFish opened this issue Jul 12, 2023 · 9 comments · Fixed by #85880
Closed

[WASM] Cannot select BUILD_VECTOR when enabling SIMD128 #63817

HazyFish opened this issue Jul 12, 2023 · 9 comments · Fixed by #85880
Labels
backend:WebAssembly crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@HazyFish
Copy link
Contributor

Description

When feature simd128 is on, the following code crashes the WebAssembly backend (both wasm32 and wasm64) with error Cannot select: v16i8 = BUILD_VECTOR

Minimal Reproduction

https://godbolt.org/z/o71M96j4P

Code

define <4 x i8> @f(<4 x i8> %0) {
BB:
  %V1 = or <4 x i8> <i8 255, i8 255, i8 255, i8 255>, %0
  %V2 = insertelement <4 x i8> %V1, i8 17, i32 1
  ret <4 x i8> %V2
}

Stack Trace

LLVM ERROR: Cannot select: t27: v16i8 = BUILD_VECTOR Constant:i32<255>, Constant:i32<17>, Constant:i32<255>, Constant:i32<255>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>
  t25: i32 = Constant<255>
  t22: i32 = Constant<17>
  t25: i32 = Constant<255>
  t25: i32 = Constant<255>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
In function: f
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=wasm64 -mattr=+simd128 <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'WebAssembly Instruction Selection' on function '@f'
 #0 0x000055f974a9115f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x354b15f)
 #1 0x000055f974a8e8b4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f5bd0016420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f5bcfae300b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f5bcfac2859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x000055f971d20a66 llvm::RISCVISAInfo::updateImplication() (.cold) RISCVISAInfo.cpp:0:0
 #6 0x000055f97484e02d llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x330802d)
 #7 0x000055f97484ff6a llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3309f6a)
 #8 0x000055f9730b8b1f (anonymous namespace)::WebAssemblyDAGToDAGISel::Select(llvm::SDNode*) WebAssemblyISelDAGToDAG.cpp:0:0
 #9 0x000055f97484a630 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3304630)
#10 0x000055f974857e44 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3311e44)
#11 0x000055f97485b4c8 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x33154c8)
#12 0x000055f97485d192 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x000055f973d306ce llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#14 0x000055f9742ca7f1 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d847f1)
#15 0x000055f9742caa39 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d84a39)
#16 0x000055f9742cb2b2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d852b2)
#17 0x000055f971ddd634 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#18 0x000055f971d25f06 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7dff06)
#19 0x00007f5bcfac4083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#20 0x000055f971dd3a1e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x88da1e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
@HazyFish
Copy link
Contributor Author

@DataCorrupted

@EugeneZelenko EugeneZelenko added backend:WebAssembly crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Jul 12, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 12, 2023

@llvm/issue-subscribers-backend-webassembly

@tlively
Copy link
Collaborator

tlively commented Jul 13, 2023

Thanks for the excellent reproducer. I'll have a look at this tomorrow.

@tlively
Copy link
Collaborator

tlively commented Jul 16, 2023

Candidate fix: https://reviews.llvm.org/D155386

@DataCorrupted
Copy link
Member

Great! Thanks.

@DataCorrupted
Copy link
Member

It seems like this patch is never applied. Now that Phabricator is offline, how can we merge it?

@EugeneZelenko
Copy link
Contributor

@DataCorrupted: Just create pull request from Phabricator patch.

@DataCorrupted
Copy link
Member

Cool, I'll come back next week and send the PR on behalf of @tlively if he hasn't by then.

@DataCorrupted DataCorrupted reopened this Mar 19, 2024
tlively added a commit to tlively/llvm-project that referenced this issue Mar 20, 2024
Previously we expected lane constants to be in the range of signed values for
each lane size, but the included test case produced large unsigned values that
fall outside that range. Allow instruction selection to proceed in this case
rather than failing.

Fixes llvm#63817.
@tlively
Copy link
Collaborator

tlively commented Mar 20, 2024

I just re-uploaded the patch as a PR with the fixes it was waiting on applied.

tlively added a commit that referenced this issue Mar 20, 2024
…5880)

Previously we expected lane constants to be in the range of signed
values for each lane size, but the included test case produced large
unsigned values that fall outside that range. Allow instruction
selection to proceed in this case rather than failing.

Fixes #63817.
chencha3 pushed a commit to chencha3/llvm-project that referenced this issue Mar 23, 2024
…vm#85880)

Previously we expected lane constants to be in the range of signed
values for each lane size, but the included test case produced large
unsigned values that fall outside that range. Allow instruction
selection to proceed in this case rather than failing.

Fixes llvm#63817.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:WebAssembly crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants