xref: /llvm-project/llvm/test/CodeGen/NVPTX/bug22322.ll (revision 4583f6d3443c8dc6605c868724e3743161954210)
1; RUN: llc < %s -mtriple=nvptx64 -mcpu=sm_20 | FileCheck %s
2; RUN: %if ptxas %{ llc < %s -mtriple=nvptx64 -mcpu=sm_20 | %ptxas-verify %}
3
4target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
5target triple = "nvptx64-nvidia-cuda"
6
7%class.float3 = type { float, float, float }
8
9; Function Attrs: nounwind
10; CHECK-LABEL: some_kernel
11define ptx_kernel void @some_kernel(ptr nocapture %dst) #0 {
12_ZL11compute_vecRK6float3jb.exit:
13  %ret_vec.sroa.8.i = alloca float, align 4
14  %0 = tail call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
15  %1 = tail call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
16  %2 = mul nsw i32 %1, %0
17  %3 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
18  %4 = add nsw i32 %2, %3
19  %5 = zext i32 %4 to i64
20  call void @llvm.lifetime.start.p0(i64 4, ptr %ret_vec.sroa.8.i)
21  %6 = and i32 %4, 15
22  %7 = icmp eq i32 %6, 0
23  %8 = select i1 %7, float 0.000000e+00, float -1.000000e+00
24  store float %8, ptr %ret_vec.sroa.8.i, align 4
25; CHECK: max.f32 %f{{[0-9]+}}, %f{{[0-9]+}}, 0f00000000
26  %9 = fcmp olt float %8, 0.000000e+00
27  %ret_vec.sroa.8.i.val = load float, ptr %ret_vec.sroa.8.i, align 4
28  %10 = select i1 %9, float 0.000000e+00, float %ret_vec.sroa.8.i.val
29  call void @llvm.lifetime.end.p0(i64 4, ptr %ret_vec.sroa.8.i)
30  %11 = getelementptr inbounds %class.float3, ptr %dst, i64 %5, i32 0
31  store float 0.000000e+00, ptr %11, align 4
32  %12 = getelementptr inbounds %class.float3, ptr %dst, i64 %5, i32 1
33  store float %10, ptr %12, align 4
34  %13 = getelementptr inbounds %class.float3, ptr %dst, i64 %5, i32 2
35  store float 0.000000e+00, ptr %13, align 4
36  ret void
37}
38
39; Function Attrs: nounwind readnone
40declare i32 @llvm.nvvm.read.ptx.sreg.ctaid.x() #1
41
42; Function Attrs: nounwind readnone
43declare i32 @llvm.nvvm.read.ptx.sreg.ntid.x() #1
44
45; Function Attrs: nounwind readnone
46declare i32 @llvm.nvvm.read.ptx.sreg.tid.x() #1
47
48; Function Attrs: nounwind
49declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #2
50
51; Function Attrs: nounwind
52declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #2
53
54attributes #0 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "stack-protector-buffer-size"="8" "no-signed-zeros-fp-math"="true" "use-soft-float"="false" }
55attributes #1 = { nounwind readnone }
56attributes #2 = { nounwind }
57
58!llvm.ident = !{!1}
59!1 = !{!"clang version 3.5.1 (tags/RELEASE_351/final)"}
60