1 ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=MEMTIME -check-prefix=SIVI -check-prefix=GCN %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=MEMTIME -check-prefix=SIVI -check-prefix=GCN %s
3 ; RUN: llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=MEMTIME -check-prefix=GCN %s
5 declare i64 @llvm.readcyclecounter() #0
7 ; GCN-LABEL: {{^}}test_readcyclecounter:
8 ; MEMTIME-DAG: s_memtime s{{\[[0-9]+:[0-9]+\]}}
9 ; GCN-DAG: s_load_dwordx2
11 ; MEMTIME: store_dwordx2
13 ; MEMTIME: s_memtime s{{\[[0-9]+:[0-9]+\]}}
14 ; MEMTIME: store_dwordx2
16 define amdgpu_kernel void @test_readcyclecounter(i64 addrspace(1)* %out) #0 {
17 %cycle0 = call i64 @llvm.readcyclecounter()
18 store volatile i64 %cycle0, i64 addrspace(1)* %out
20 %cycle1 = call i64 @llvm.readcyclecounter()
21 store volatile i64 %cycle1, i64 addrspace(1)* %out
25 ; This test used to crash in ScheduleDAG.
27 ; GCN-LABEL: {{^}}test_readcyclecounter_smem:
28 ; MEMTIME-DAG: s_memtime
29 ; GCN-DAG: s_load_dword
30 define amdgpu_cs i32 @test_readcyclecounter_smem(i64 addrspace(4)* inreg %in) #0 {
31 %cycle0 = call i64 @llvm.readcyclecounter()
32 %in.v = load i64, i64 addrspace(4)* %in
33 %r.64 = add i64 %cycle0, %in.v
34 %r.32 = trunc i64 %r.64 to i32
38 attributes #0 = { nounwind }