blob: d59699ace0ad8b1907ebe335c7185e966cabafd6 [file] [log] [blame]
Justin Holewinski23df6592015-01-26 19:11:20 +00001; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
2
3target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
4target triple = "nvptx64-nvidia-cuda"
5
6%class.float3 = type { float, float, float }
7
8; Function Attrs: nounwind
9; CHECK-LABEL: some_kernel
10define void @some_kernel(%class.float3* nocapture %dst) #0 {
11_ZL11compute_vecRK6float3jb.exit:
12 %ret_vec.sroa.8.i = alloca float, align 4
Justin Bognera466cc32016-07-07 16:40:17 +000013 %0 = tail call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
14 %1 = tail call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
Justin Holewinski23df6592015-01-26 19:11:20 +000015 %2 = mul nsw i32 %1, %0
Justin Bognera466cc32016-07-07 16:40:17 +000016 %3 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
Justin Holewinski23df6592015-01-26 19:11:20 +000017 %4 = add nsw i32 %2, %3
18 %5 = zext i32 %4 to i64
19 %6 = bitcast float* %ret_vec.sroa.8.i to i8*
Matt Arsenaultf10061e2017-04-10 20:18:21 +000020 call void @llvm.lifetime.start.p0i8(i64 4, i8* %6)
Justin Holewinski23df6592015-01-26 19:11:20 +000021 %7 = and i32 %4, 15
22 %8 = icmp eq i32 %7, 0
23 %9 = select i1 %8, float 0.000000e+00, float -1.000000e+00
24 store float %9, float* %ret_vec.sroa.8.i, align 4
Justin Lebarb5e88492016-09-09 21:07:26 +000025; CHECK: max.f32 %f{{[0-9]+}}, %f{{[0-9]+}}, 0f00000000
Justin Holewinski23df6592015-01-26 19:11:20 +000026 %10 = fcmp olt float %9, 0.000000e+00
David Blaikiea79ac142015-02-27 21:17:42 +000027 %ret_vec.sroa.8.i.val = load float, float* %ret_vec.sroa.8.i, align 4
Justin Holewinski23df6592015-01-26 19:11:20 +000028 %11 = select i1 %10, float 0.000000e+00, float %ret_vec.sroa.8.i.val
Matt Arsenaultf10061e2017-04-10 20:18:21 +000029 call void @llvm.lifetime.end.p0i8(i64 4, i8* %6)
David Blaikie79e6c742015-02-27 19:29:02 +000030 %12 = getelementptr inbounds %class.float3, %class.float3* %dst, i64 %5, i32 0
Justin Holewinski23df6592015-01-26 19:11:20 +000031 store float 0.000000e+00, float* %12, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000032 %13 = getelementptr inbounds %class.float3, %class.float3* %dst, i64 %5, i32 1
Justin Holewinski23df6592015-01-26 19:11:20 +000033 store float %11, float* %13, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000034 %14 = getelementptr inbounds %class.float3, %class.float3* %dst, i64 %5, i32 2
Justin Holewinski23df6592015-01-26 19:11:20 +000035 store float 0.000000e+00, float* %14, align 4
36 ret void
37}
38
39; Function Attrs: nounwind readnone
Justin Bognera466cc32016-07-07 16:40:17 +000040declare i32 @llvm.nvvm.read.ptx.sreg.ctaid.x() #1
Justin Holewinski23df6592015-01-26 19:11:20 +000041
42; Function Attrs: nounwind readnone
Justin Bognera466cc32016-07-07 16:40:17 +000043declare i32 @llvm.nvvm.read.ptx.sreg.ntid.x() #1
Justin Holewinski23df6592015-01-26 19:11:20 +000044
45; Function Attrs: nounwind readnone
Justin Bognera466cc32016-07-07 16:40:17 +000046declare i32 @llvm.nvvm.read.ptx.sreg.tid.x() #1
Justin Holewinski23df6592015-01-26 19:11:20 +000047
48; Function Attrs: nounwind
Matt Arsenaultf10061e2017-04-10 20:18:21 +000049declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2
Justin Holewinski23df6592015-01-26 19:11:20 +000050
51; Function Attrs: nounwind
Matt Arsenaultf10061e2017-04-10 20:18:21 +000052declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2
Justin Holewinski23df6592015-01-26 19:11:20 +000053
Matt Arsenault12013012018-08-12 19:09:12 +000054attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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" }
Justin Holewinski23df6592015-01-26 19:11:20 +000055attributes #1 = { nounwind readnone }
56attributes #2 = { nounwind }
57
58!nvvm.annotations = !{!0}
59!llvm.ident = !{!1}
60
61!0 = !{void (%class.float3*)* @some_kernel, !"kernel", i32 1}
62!1 = !{!"clang version 3.5.1 (tags/RELEASE_351/final)"}