<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54635>54635</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AMDGPU] LLVM ERROR: Cannot select (AtomicCmpSwap)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AMDGPU
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
chichunchen
</td>
</tr>
</table>
<pre>
live demo: https://godbolt.org/z/r1nq3EMx5
Command: llc -mtriple=amdgcn-amd-amdhsa -disable-promote-alloca-to-lds -mcpu=gfx908 -amdgpu-dump-hsa-metadata -filetype=asm bugpoint-reduced-simplified.ll
```
; ModuleID = '<stdin>'
source_filename = "llvm-link"
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7"
target triple = "amdgcn-amd-amdhsa"
define amdgpu_kernel void @"test"() local_unnamed_addr #0 {
entry:
br label %for.cond
for.cond: ; preds = %entry
br label %while.cond
while.cond: ; preds = %for.cond
br i1 undef, label %for.cond.i74, label %while.body
while.body: ; preds = %while.cond
%0 = cmpxchg i32 addrspace(5)* undef, i32 undef, i32 undef monotonic monotonic, align 4
unreachable
for.cond.i74: ; preds = %for.cond.i74, %while.cond
br label %for.cond.i74, !llvm.loop !1, !cray.depth !3
}
attributes #0 = { "unsafe-fp-math"="false" }
!llvm.module.flags = !{!0}
!0 = !{i32 7, !"Dwarf Version", i32 4}
!1 = distinct !{!1, !2}
!2 = !{!"llvm.loop.mustprogress"}
!3 = !{i32 1}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVVtv4ygU_jXOCyKy8S15yEPadEYrTbWrjnZeKwzYZovBa3Da7q_fA7YnbpORJnKwD3znnO9cgMrw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