<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97533>97533</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assertion failure in TwoAddressInstructionPass
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:X86,
llvm:crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nikic
</td>
</tr>
</table>
<pre>
```llvm
; RUN: llc < %s
target triple = "x86_64-unknown-linux-gnu"
define ptr @test(ptr %ptr, i8 %arg, i1 %cond) {
entry:
br i1 %cond, label %if, label %exit
if:
%idx = zext i8 %arg to i64
%gep1 = getelementptr ptr, ptr %ptr, i64 %idx
%ptr2 = load ptr, ptr %gep1, align 8
%gep2 = getelementptr i64, ptr %ptr2, i64 %idx
br label %exit
exit:
%phi = phi ptr [ %gep2, %if ], [ null, %entry ]
ret ptr %phi
}
```
Results in:
```
llc: /home/npopov/repos/llvm-project/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1461: bool (anonymous namespace)::TwoAddressInstructionPass::collectTiedOperands(MachineInstr *, TiedOperandMap &): Assertion `SrcReg && SrcMO.isUse() && "two address instruction invalid"' failed.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VE1v4zYQ_TWjCxFDGn0fdPAHXPSQbpHdBXorKGossaFJgaQSp7--IOUmdrABDAtPM3zvzQfFnZOjJuqg3EF5SPjiJ2M7LZ-lSHozvHVQpetPqZczpAdIt5Dv2NPPPyDfMqUEg3zPAEu3Bj23I3nmrZwVMcgPDBAvTfV3VTws-lmbV_2gpF4uD6NeAPFKGf8HOklNbPaWQZF6ch6wiQjL2VvAPZNNANyOEWQBCKMHwJZBvVtpSHv7BvmVlLHe3mXumeI9qfBCnu4gXaS_9SNPNywhfbjEiv6li_9wwrxhsipu8kaas5g4kidFZ9I-VHEt4VNBVXGlviGYvcVIoAwfPp0L5AFyJUfNmntZ_IVs8HYni7_W7e3XnYj4rhfzJKNWeEbqcve_h0Afm8ugPERQ7phelLoG4nxibKWz5N_dTfIqW1-j7_t3a-eJ3KK8Y1K_m_qUp5QI-wl4nMyZAI96NrN5ATxamo0DPIZ9fpit-YeEv8LwkD3gcW8G-o004PHHq9kOgyXnftfO20V4afSf3LmNmGfIt1lRZUGoNyY0ruHa6LezWRzT_Exu5oIA2-Ay337JtYaFUYqE_yFp-DaT5XpwgM0jF5PUFE8wwG3o4U3KI58ZYLVqsK1zZAMrgyr9bsUTjWu0Yt-tePy2ke6nI8Am3pc1AIj-1TC-OmPywxqT-oUrOYRbijU7calo2HxqdzJ0-dDmLU-oy-qsbdssxTaZulRkbckrXnBBVUF9mQ0NnnpKe8HblGeJ7DDFIq3TPK2zOq02bdrUp7wRVJzqvk8JipTOXKpNmM3G2DGRzi3UtXWZ50ncVRc_XIg9F8-kB8i3fzVV9LsHxDjTfCssd1N4WR4S28W598vooEiVdN590HvpFXUfTQwVL5aY1OzL2SWLVd3k_RyniEfA4yj9tPQbYc43e3W_bbGQsIVrLS8d_hcAAP__Vv6lZw">