Issue 175125
Summary [WebAssembly] Backend crash: Cannot select v2f64 insert_vector_elt with SIMD
Labels new issue
Assignees
Reporter thedaneeffect
    ## Summary
LLVM crashes during WebAssembly instruction selection when compiling code with `-msimd128` enabled.

## Environment
- **Clang**: 22.0.0git (bundled with Emscripten 4.0.22-git, installed via Homebrew)
- **Target**: wasm32-unknown-emscripten
- **OS**: macOS 15.6.1 (Apple Silicon / arm64)
- **Project**: Godot Engine ([commit 6f15a05b](https://github.com/godotengine/godot/commit/6f15a05b6cf5f87de80e09f960a0e7a7449db640))

## Reproduction
Building Godot Engine for web platform:
```
scons platform=web target=template_release
```

Key flags from the failing command:
- `-target wasm32-unknown-emscripten`
- `-msimd128`
- `-Os`
- `-std=gnu++17`

Source file: [thirdparty/vhacd/src/FloatMath.cpp](https://github.com/godotengine/godot/blob/6f15a05b6cf5f87de80e09f960a0e7a7449db640/thirdparty/vhacd/src/FloatMath.cpp)

## Error
```
fatal error: error in backend: Cannot select: 0x106b7da90: v2f64 = insert_vector_elt 0x10685f470, 0x106861b00,
      Constant:i32<1>
 0x10685f470: v2f64 = scalar_to_vector 0x10685d810
    0x10685d810: v2f64,ch = load<(load (s128) from %ir.35, align 8, !tbaa !126)> 0x10610fc18, 0x106862190, undef:i32
      0x106862190: i32 = add nuw 0x106b7e2e0, Constant:i32<8>
        0x106b7e2e0: i32,ch = CopyFromReg 0x10610fc18, Register:i32 %16
  0x106861b00: v2f64 = splat_vector 0x10685f860
 0x10685f860: f64,ch = load<(dereferenceable load (s64) from %ir.31, !tbaa !56)> 0x10610fc18, 0x106fd2470, undef:i32
      0x106fd2470: i32 = add nuw 0x106b7d470, Constant:i32<8>
        0x106b7d470: i32,ch = CopyFromReg 0x10610fc18, Register:i32 %15
In function: _ZN10FLOAT_MATH13MyVertexIndex8getIndexEPKdRb
```

The crash occurs during WebAssembly instruction selection (pass 4 in stack dump).

## Stack Trace
```
 #7 llvm::report_fatal_error(llvm::Twine const&, bool)
 #8 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int)
 #9 (anonymous namespace)::WebAssemblyDAGToDAGISel::Select(llvm::SDNode*)
#10 llvm::SelectionDAGISel::DoInstructionSelection()
#11 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
#12 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
#13 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
#14 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&)
#15 llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
```

## Attachments
Preprocessed source and run script available at:
https://gist.github.com/thedaneeffect/1ecaef7380046ef5de812fa355e6199f

- `FloatMath-8c5533.cpp` - Preprocessed source
- `FloatMath-8c5533.sh` - Run script
- `output.txt` - Full build output with complete stack trace

**Note:** The crash backtrace `.crash` file mentioned in the compiler output was not actually saved to disk by macOS.

## Related
- Emscripten issue: https://github.com/emscripten-core/emscripten/issues/26060
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to