1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=GCN %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=VI -check-prefix=GCN %s
3
4declare i64 @llvm.readcyclecounter() #0
5
6; GCN-LABEL: {{^}}test_readcyclecounter:
7; SI-DAG: s_memtime s{{\[[0-9]+:[0-9]+\]}}
8; VI-DAG: s_memrealtime s{{\[[0-9]+:[0-9]+\]}}
9; GCN-DAG: s_load_dwordx2
10; GCN: lgkmcnt
11; GCN: buffer_store_dwordx2
12; GCN-NOT: lgkmcnt
13; SI: s_memtime s{{\[[0-9]+:[0-9]+\]}}
14; VI: s_memrealtime s{{\[[0-9]+:[0-9]+\]}}
15; GCN: buffer_store_dwordx2
16define void @test_readcyclecounter(i64 addrspace(1)* %out) #0 {
17  %cycle0 = call i64 @llvm.readcyclecounter()
18  store volatile i64 %cycle0, i64 addrspace(1)* %out
19
20  %cycle1 = call i64 @llvm.readcyclecounter()
21  store volatile i64 %cycle1, i64 addrspace(1)* %out
22  ret void
23}
24
25attributes #0 = { nounwind }
26