1 ; RUN: llc -global-isel=0 -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=MEMTIME -check-prefix=SIVI -check-prefix=GCN %s
2 ; -global-isel=1 SI run line skipped since store not yet implemented.
3 ; RUN: llc -global-isel=0 -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=MEMTIME -check-prefix=SIVI -check-prefix=GCN %s
4 ; RUN: llc -global-isel=1 -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=MEMTIME -check-prefix=SIVI -check-prefix=GCN %s
5 ; RUN: llc -global-isel=0 -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=MEMTIME -check-prefix=GCN %s
6 ; RUN: llc -global-isel=1 -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=MEMTIME -check-prefix=GCN %s
7 ; RUN: llc -global-isel=0 -march=amdgcn -mcpu=gfx1030 -verify-machineinstrs < %s | FileCheck -check-prefixes=GETREG,GETREG-SDAG -check-prefix=GCN %s
8 ; RUN: llc -global-isel=1 -march=amdgcn -mcpu=gfx1030 -verify-machineinstrs < %s | FileCheck -check-prefixes=GETREG,GETREG-GISEL -check-prefix=GCN %s
9 ; RUN: llc -global-isel=0 -march=amdgcn -mcpu=gfx1100 -verify-machineinstrs -amdgpu-enable-vopd=0 < %s | FileCheck -check-prefixes=GETREG,GETREG-SDAG -check-prefix=GCN %s
10 ; RUN: llc -global-isel=1 -march=amdgcn -mcpu=gfx1100 -verify-machineinstrs -amdgpu-enable-vopd=0 < %s | FileCheck -check-prefixes=GETREG,GETREG-GISEL -check-prefix=GCN %s
12 declare i64 @llvm.readcyclecounter() #0
14 ; GCN-LABEL: {{^}}test_readcyclecounter:
15 ; MEMTIME-DAG: s_memtime s{{\[[0-9]+:[0-9]+\]}}
16 ; GCN-DAG: s_load_{{dwordx2|b64}}
18 ; MEMTIME: store_dwordx2
20 ; MEMTIME: s_memtime s{{\[[0-9]+:[0-9]+\]}}
21 ; MEMTIME: store_dwordx2
23 ; GETREG-GISEL-DAG: s_mov_b32 s[[SZERO:[0-9]+]], 0
24 ; GETREG-GISEL-DAG: v_mov_b32_e32 v[[ZERO:[0-9]+]], s[[SZERO]]
25 ; GETREG-SDAG-DAG: v_mov_b32_e32 v[[ZERO:[0-9]+]], 0
26 ; GETREG-DAG: s_getreg_b32 [[CNT1:s[0-9]+]], hwreg(HW_REG_SHADER_CYCLES, 0, 20)
27 ; GETREG-DAG: v_mov_b32_e32 v[[VCNT1:[0-9]+]], [[CNT1]]
28 ; GETREG: global_store_{{dwordx2|b64}} v{{.+}}, v[[[VCNT1]]:[[ZERO]]]
29 ; GETREG: s_getreg_b32 [[CNT2:s[0-9]+]], hwreg(HW_REG_SHADER_CYCLES, 0, 20)
30 ; GETREG: v_mov_b32_e32 v[[VCNT2:[0-9]+]], [[CNT2]]
31 ; GETREG: global_store_{{dwordx2|b64}} v{{.+}}, v[[[VCNT2]]:[[ZERO]]]
33 define amdgpu_kernel void @test_readcyclecounter(ptr addrspace(1) %out) #0 {
34 %cycle0 = call i64 @llvm.readcyclecounter()
35 store volatile i64 %cycle0, ptr addrspace(1) %out
37 %cycle1 = call i64 @llvm.readcyclecounter()
38 store volatile i64 %cycle1, ptr addrspace(1) %out
42 ; This test used to crash in ScheduleDAG.
44 ; GCN-LABEL: {{^}}test_readcyclecounter_smem:
45 ; MEMTIME-DAG: s_memtime
46 ; GCN-DAG: s_load_{{dword|b32|b64}}
47 ; GETREG-DAG: s_getreg_b32 s{{[0-9]+}}, hwreg(HW_REG_SHADER_CYCLES, 0, 20)
48 define amdgpu_cs i32 @test_readcyclecounter_smem(ptr addrspace(4) inreg %in) #0 {
49 %cycle0 = call i64 @llvm.readcyclecounter()
50 %in.v = load i64, ptr addrspace(4) %in
51 %r.64 = add i64 %cycle0, %in.v
52 %r.32 = trunc i64 %r.64 to i32
56 attributes #0 = { nounwind }