• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck %s
2
3declare i32 @llvm.amdgcn.readfirstlane(i32) #0
4
5; CHECK-LABEL: {{^}}test_readfirstlane:
6; CHECK: v_readfirstlane_b32 s{{[0-9]+}}, v{{[0-9]+}}
7define amdgpu_kernel void @test_readfirstlane(i32 addrspace(1)* %out, i32 %src) #1 {
8  %readfirstlane = call i32 @llvm.amdgcn.readfirstlane(i32 %src)
9  store i32 %readfirstlane, i32 addrspace(1)* %out, align 4
10  ret void
11}
12
13; CHECK-LABEL: {{^}}test_readfirstlane_imm:
14; CHECK: v_mov_b32_e32 [[VVAL:v[0-9]]], 32
15; CHECK: v_readfirstlane_b32 s{{[0-9]+}}, [[VVAL]]
16define amdgpu_kernel void @test_readfirstlane_imm(i32 addrspace(1)* %out) #1 {
17  %readfirstlane = call i32 @llvm.amdgcn.readfirstlane(i32 32)
18  store i32 %readfirstlane, i32 addrspace(1)* %out, align 4
19  ret void
20}
21
22; TODO: m0 should be folded.
23; CHECK-LABEL: {{^}}test_readfirstlane_m0:
24; CHECK: s_mov_b32 m0, -1
25; CHECK: s_mov_b32 [[COPY_M0:s[0-9]+]], m0
26; CHECK: v_mov_b32_e32 [[VVAL:v[0-9]]], [[COPY_M0]]
27; CHECK: v_readfirstlane_b32 s{{[0-9]+}}, [[VVAL]]
28define amdgpu_kernel void @test_readfirstlane_m0(i32 addrspace(1)* %out) #1 {
29  %m0 = call i32 asm "s_mov_b32 m0, -1", "={M0}"()
30  %readfirstlane = call i32 @llvm.amdgcn.readfirstlane(i32 %m0)
31  store i32 %readfirstlane, i32 addrspace(1)* %out, align 4
32  ret void
33}
34
35attributes #0 = { nounwind readnone convergent }
36attributes #1 = { nounwind }
37