<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116809>116809</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SimpleLoopUnswitch][LICM] Assertion `NewAccess != nullptr && "Tried to create a memory access for a " "non-memory touching instruction"'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
DianQK
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DianQK
</td>
</tr>
</table>
<pre>
The following IR triggers the assertion mentioned in the title:
```llvm
; opt -passes='loop-mssa(simple-loop-unswitch<nontrivial>,licm)'
define i32 @foo(i1 %arg, ptr %arg1) {
bb:
br label %bb2
bb2: ; preds = %bb2, %bb
%i = select i1 %arg, ptr %arg1, ptr @bar
%i3 = call i32 %i()
br i1 %arg, label %bb2, label %bb4
bb4: ; preds = %bb2
ret i32 %i3
}
declare i32 @bar() nounwind willreturn memory(none)
```
https://llvm.godbolt.org/z/bj79jxo8x
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVM2O4zYMfhr6IiSwKP_l4EMmboBFtwXabh9AthlbA1kyJHmy26cvZHsyE6A9bJBEJiVS30fys_ReDYaohvwFEBslzR-_AiLkTSKXMFpXb76ktf2P-ttI7Ga1tndlBvblTxacGgZynoWRmPSeXFDWsIlMXKlnyqxbQQVNIM6QNpC-_xfp9tX6bdpd4oXZObDDHHN5EA1gqa2dD5P3ErDyapo1HVbXYvxdhW4EcTHWBKfelNQgfgG8aNVNgCfAcsvb000ZYkoggyy9WQtYKc4Ac-kGwAubg9stDnhiUL5sgW37AM1Y65iWLel4sm3xM5doijOL-GdHvWcgmvdjeNme3tMA5mrd96SpC-z_gexmlrbSfY4Wa3gntd4oYa4Aq0j4A-lT1ifYz3b2TCOLNH7q85-cdxyOwgOh2C8qm8839tRp6R6tiURXJszYxdyV6dldae0oLC6O1WTdD8DKWEMPuo85-px3DGH2sXd4BbzGCTsOtm-tDkcba3L9B_Davpan1--2-p70tehP4iQTqnkpMMUiQ56MdZpz3smyL8ubkClyoioXfZHfZNZ3adEnqsYUM875iWdYpvyYCV6IqsryHrkgeYMspUkqfVwxWDckyvuFas6LKj0layf8Lr9VCOLcOenHXYSujs5DuwweslQrH_xHplVVMfavVRZfrZ3_fhdF3kD-8vXL5TfIG3Z-KBOK9He6n7uOvGeAPPbMLFpvc1cAFgwQvzlFPQuWdY5kICb30jO5Bd6sYzIejD9jzWHfDnbpxvhqUMYHt3TxykgEy2Rxun5uyqDCuLTHzk57h_blMDv7Sl0AvK6l8oDXvVpvNf4bAAD__yj6XAw">