<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58914>58914</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Crash in TwoAddressInstruction: assertion isReg() && "Wrong MachineOperand accessor"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jreiffers
</td>
</tr>
</table>
<pre>
The crash happens when rewriting the VMOVUPDZ256rmk instruction (the code seems to assume the stack argument is a register). The following test reproduces it for me.
```
# RUN: llc -x mir < %s -mcpu=skylake-avx512 -O1 -run-pass=livevars,twoaddressinstruction | FileCheck %s
---
name: main
tracksRegLiveness: true
stack:
- { id: 0, offset: 0, size: 768 }
body: |
bb.0:
successors: %bb.1(0x7c000000)
liveins: $rcx, $ymm0
%0:gr64_nosp = COPY $rcx
%1:vr256x = COPY $ymm0
bb.1:
successors: %bb.1(0x7c000000)
%2:vk16wm = COPY $rsp
%3:vr256x = VMOVUPDZ256rmk %1, killed %2, %stack.0, 8, %0, 0, $noreg
RET %3
...
# CHECK: main
```
Stack trace:
```
assertion failed at [(...)/include/llvm/CodeGen/MachineOperand.h:385] in bool llvm::MachineOperand::isDead() const: isReg() &&
"Wrong MachineOperand accessor"
@ 0x5628a05a8d24 __assert_fail
@ 0x56289e805762 llvm::X86InstrInfo::convertToThreeAddress()
@ 0x56289f2420d9 (anonymous namespace)::TwoAddressInstructionPass::tryInstructionTransform()
@ 0x56289f23ea9e (anonymous namespace)::TwoAddressInstructionPass::runOnMachineFunction()
@ 0x56289ed2c1fd llvm::MachineFunctionPass::runOnFunction()
(snip)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVUtz2zgM_jXyhSONRFmvgw6p3exmdrvJZN3u45KhJMhiLZEakrKd_voFKae2s-nkUI_GIgkQ-AB8gCrZPJebDkitmO5Ix8YRhCaHDgRRcFDccLElBh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