<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57658>57658</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[WASM64] Infinite recursion in `VectorLegalizer::LegalizeOp(llvm::SDValue)`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DataCorrupted
</td>
</tr>
</table>
<pre>
When compiling the following code with `llc PoC.ll -mtriple=wasm64`.
The bug can be reproduced on the latest commit `3875c38adf4`
You can also find a reproduction here: https://llvm.godbolt.org/z/o4oKo4zx8
```
define void @f() {
BB:
%I = insertelement <8 x double> zeroinitializer, double 0.000000e+00, i8 0
%F = fneg <8 x double> %I
%B3 = fmul <8 x double> %I, %F
%B1 = fmul <8 x double> %F, %B3
%B2 = fmul <8 x double> %F, %I
%B = fmul <8 x double> %B2, %B1
store <8 x double> %B, <8 x double>* undef, align 64
ret void
}
```
The error report is shown here:
```
peter@carcinoma:~/aflplusplus-isel/fuzzing/wasm64/default$ llc PoC.ll -mtriple=wasm64
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/peter/aflplusplus-isel/llvm-fix/build-release/bin/llc PoC.ll -mtriple=wasm64
1. Running pass 'Function Pass Manager' on module 'PoC.ll'.
2. Running pass 'WebAssembly Instruction Selection' on function '@f'
#0 0x0000000001e0acb3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/peter/aflplusplus-isel/llvm-fix/build-release/bin/llc+0x1e0acb3)
#1 0x0000000001e08bce llvm::sys::RunSignalHandlers() (/home/peter/aflplusplus-isel/llvm-fix/build-release/bin/llc+0x1e08bce)
#2 0x0000000001e0b03f SignalHandler(int) Signals.cpp:0:0
#3 0x00007f89c6c7f980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#4 0x0000000001cc27ab (anonymous namespace)::VectorLegalizer::LegalizeOp(llvm::SDValue) LegalizeVectorOps.cpp:0:0
#5 0x0000000001cc27b0 (anonymous namespace)::VectorLegalizer::LegalizeOp(llvm::SDValue) LegalizeVectorOps.cpp:0:0
#6 0x0000000001cc27b0 (anonymous namespace)::VectorLegalizer::LegalizeOp(llvm::SDValue) LegalizeVectorOps.cpp:0:0
#7 0x0000000001cc27b0 (anonymous namespace)::VectorLegalizer::LegalizeOp(llvm::SDValue) LegalizeVectorOps.cpp:0:0
......
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVttu4zYQ_Rr5hbBAU7IlP_jBjmN00V1s0Cw26FNASSObLUUKvGycfH2HlJzE2SQtFi26giXzNmfOzHCGrHRzv7o5gCK17nohhdoTdwDSain1XejVugFyJ9yBkGRBpazJlb5IpSTTzhnRS0iy7R233SLH6TSh24SuvyBC5VGWK1IBMdAb3fgaGqJVhJfcgXVBZydcwM3KYl5nJW_aADOg_K59RODSatIK1RD-COUEIh3AoPY1IQfneouthO3wJ-W3Lt3rptLSpdrscegBX53rX3X-cCwH9PGLyoZf7DaAeoB806IhSU7bhJUJW5Kk2Azzm03QEpvoDjb_QNB6IpQF40BCBwqtyS5KciSN9lVwziV5AKOFEk5wKbCdsItxktCUxgcStqE0TIiS0Gf4u4jfKth_DxvUP1u6yYa1nZdvrEX4APlcZva-zG6U2WTPhdg_Ezoj977Ihp0UzU5C1mkDry-Oa19MJGxNvMLwhUn0814R3JAjlgEXQzqGvNi-GvunrQvGaBO2mjaOCEvsQd897rZ3dk8PDsOb05qbWijd8bC8QG473speehveqbAgcaj1Dw-YX9gas4ftkD730iUsJ-_mWVR29fFyfX1JrK9CCvGYbyNlp19kxB7T11cpptuYHuPfFJPpD6hR405Y68Fig3BMNKFq6THvQ67WhtsDqXj9pzO8hjHFrx0OkMZ3_aNPaEric2X03vCOcLP3ISMCDwzc7qA73Oi7wUuv-iRyasURm5UXspkaTCpug1QlVFzwd26ZjSR-80qF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