[DAGCombiner] Eliminate dead stores to stack.
[llvm-complete.git] / test / CodeGen / AMDGPU / llvm.amdgcn.readfirstlane.ll
blob9f5c809455ea35d63cb79db59d8c1b8fe1667c93
1 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck %s
3 declare i32 @llvm.amdgcn.readfirstlane(i32) #0
5 ; CHECK-LABEL: {{^}}test_readfirstlane:
6 ; CHECK: v_readfirstlane_b32 s{{[0-9]+}}, v{{[0-9]+}}
7 define 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
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]]
16 define 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
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]]
28 define 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
35 attributes #0 = { nounwind readnone convergent }
36 attributes #1 = { nounwind }