<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107854>107854</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LoopVectorize/VPlan asserts "underlying instruction may write to memory" (via PoCL's work-group generation from an OpenCL C code)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pjaaskel
</td>
</tr>
</table>
<pre>
I cannot reproduce this one from C/C++, but only via PoCL-generated work-group functions which can sometimes be a bit ... involved. Attached is a reproducer .ll, which produces the crash. It originates from an OpenCL C kernel which has a volatile int as the loop iteration variable, which PoCL (currently, this is a WiP to clean up) converts to per-WI variables. It somehow sneaks the loop down to the assert point and then fails because the load is a volatile. I'll try to minimize the test case.
```
opt --passes=loop-vectorize vplan-crash.ll -S -o -
opt: /home/pjaaskel/src/chipStar/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:80: bool llvm::VPRecipeBase::mayWriteToMemory() const: Assertion `(!I || !I->mayWriteToMemory()) && "underlying instruction may write to memory"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
...
```
[vplan-crash.ll.gz](https://github.com/user-attachments/files/16930255/vplan-crash.ll.gz)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVN1upDgTfRpzUwLRBgJccNHpBClSPn3RZjS5LkwFPDE2sg2tnqdfmSaTjDJaaVdC_JSpU6dO_aBzctBEDStuWXEX4eJHY5v5B6J7IxV1pr80DyBQa-PB0mxNvwgCP0oHRhO8WjPBifH2xPjtdp2gWzwYrS6wSoQnc3qMB9Jk0VMPZ2Pf4sGaZYbXRQsvjXZwHqUYQxBwZiIvJ3LQESB00kOSJCD1atRKfQJH71GM1IN0gB-ELCRKhdhXqN3qwI8EwqIbE3jwYKwcpEZP7sobNfx_Jn16hBO8kdWkdv8RA_pqFHq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