<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65025>65025</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Live AND erased after cmpxchg + branch on RISC-V
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MaxHearnden
</td>
</tr>
</table>
<pre>
on llvm 16.0.6 run `llc --march riscv64 --mattr=+a -O3 test.ll`
test.ll
```
define ptr @cmpxchg_masked_and_branch1(ptr %ptr, i8 signext %cmp, i8 signext %val) nounwind {
do_cmpxchg:
%0 = cmpxchg ptr %ptr, i8 %cmp, i8 %val seq_cst seq_cst
%1 = extractvalue { i8, i1 } %0, 1
%2 = select i1 %1, ptr %ptr, ptr null
br i1 %1, label %returnptr, label %exit
returnptr:
ret ptr %2
exit:
ret ptr null
}
```
repeat with the branch and labels removed to see the missing AND.
This was introduced in https://github.com/llvm/llvm-project/commit/ce381281940fb6a9cc2fa1a16fa36bf0911f43f1
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUU02PmzoU_TVmcxXkDyCwYDGZKHpPeh9SW3UbGfsS3BqT2iaT_vsKk0xmNN1UiuSc63PvOT42MgRzcogtKXek3GdyjsPk23_l9S-U3ml0WTfpn-3kwNrLCKzKaV6Bnx2QilqrYLMZpVcDeBPUpSoSjtETsSd8J2Hzv4CIIebWkooSuif06Y4TWKrrL0GNvXEI5-iBFFSN56saTsdRhu-oj9LpY-elUwMjvE4cXp6jJ_wZTA3pKNe4FNV4_li8SEt4A26a3YtxGsh2d_OwSk_Hmx4RtxIsbRSI2MNtCz6ovlNbVSDgj6MK8b6-GcbSMLxGL1W8SDvjYgNMnQYwINt90lwge9PHU19AiyomHi_ZwnlvZ0FuvkcL0Pm3XCs7tAvyGGfvbj2vVbyam9PH_iMIj_Euxtda4n8kPPTJdv_bO_Z4RhnhxcQB4oCwXilIp1czATyO0wU1xAkCYiKNJgTjTvD03z5fx3wZTIAXGcC46Cc9K9RgHAwxnsPiix8IP5xMHOYuV9NI-GF5wrdlc_bTN1SR8IOaxtGkPyhqxmvWFLTvKtkoxXvJJKt6Kaqupw1jfSF6lulW6EY0MsOWVY1gZckZzYa2VrUuRMFE2Wz7CktWNyWjgiOtGtGwPjMtp1zQmm9ZVQpB86rsZC3rrtBKIlYFKSiO0th88ZhP_pSZEGZsq5LyMlvTuX-rvk0H6eZTIAW1JsTwaIsmWmz_MRdcEgP0MqAG2Uf0r0-Z8N09-8nBp78_P2--ZrO37R9HmEwGwg_J568AAAD__wsdTv8">