diff options
Diffstat (limited to 'test/CodeGen/PTX')
-rw-r--r-- | test/CodeGen/PTX/add.ll | 70 | ||||
-rw-r--r-- | test/CodeGen/PTX/bitwise.ll | 24 | ||||
-rw-r--r-- | test/CodeGen/PTX/bra.ll | 24 | ||||
-rw-r--r-- | test/CodeGen/PTX/exit.ll | 2 | ||||
-rw-r--r-- | test/CodeGen/PTX/fdiv-sm10.ll | 15 | ||||
-rw-r--r-- | test/CodeGen/PTX/fdiv-sm13.ll | 15 | ||||
-rw-r--r-- | test/CodeGen/PTX/intrinsic.ll | 281 | ||||
-rw-r--r-- | test/CodeGen/PTX/ld.ll | 431 | ||||
-rw-r--r-- | test/CodeGen/PTX/llvm-intrinsic.ll | 56 | ||||
-rw-r--r-- | test/CodeGen/PTX/mad.ll | 17 | ||||
-rw-r--r-- | test/CodeGen/PTX/mov.ll | 59 | ||||
-rw-r--r-- | test/CodeGen/PTX/mul.ll | 39 | ||||
-rw-r--r-- | test/CodeGen/PTX/options.ll | 8 | ||||
-rw-r--r-- | test/CodeGen/PTX/parameter-order.ll | 8 | ||||
-rw-r--r-- | test/CodeGen/PTX/ret.ll | 2 | ||||
-rw-r--r-- | test/CodeGen/PTX/setp.ll | 134 | ||||
-rw-r--r-- | test/CodeGen/PTX/shl.ll | 2 | ||||
-rw-r--r-- | test/CodeGen/PTX/shr.ll | 2 | ||||
-rw-r--r-- | test/CodeGen/PTX/st.ll | 389 | ||||
-rw-r--r-- | test/CodeGen/PTX/sub.ll | 70 |
20 files changed, 1563 insertions, 85 deletions
diff --git a/test/CodeGen/PTX/add.ll b/test/CodeGen/PTX/add.ll index 1259d03e96c9..235b00e8782f 100644 --- a/test/CodeGen/PTX/add.ll +++ b/test/CodeGen/PTX/add.ll @@ -1,15 +1,71 @@ -; RUN: llc < %s -march=ptx | FileCheck %s +; RUN: llc < %s -march=ptx32 | FileCheck %s -define ptx_device i32 @t1(i32 %x, i32 %y) { -; CHECK: add.s32 r0, r1, r2; +define ptx_device i16 @t1_u16(i16 %x, i16 %y) { +; CHECK: add.u16 rh0, rh1, rh2; +; CHECK-NEXT: ret; + %z = add i16 %x, %y + ret i16 %z +} + +define ptx_device i32 @t1_u32(i32 %x, i32 %y) { +; CHECK: add.u32 r0, r1, r2; +; CHECK-NEXT: ret; %z = add i32 %x, %y -; CHECK: ret; ret i32 %z } -define ptx_device i32 @t2(i32 %x) { -; CHECK: add.s32 r0, r1, 1; +define ptx_device i64 @t1_u64(i64 %x, i64 %y) { +; CHECK: add.u64 rd0, rd1, rd2; +; CHECK-NEXT: ret; + %z = add i64 %x, %y + ret i64 %z +} + +define ptx_device float @t1_f32(float %x, float %y) { +; CHECK: add.f32 f0, f1, f2 +; CHECK-NEXT: ret; + %z = fadd float %x, %y + ret float %z +} + +define ptx_device double @t1_f64(double %x, double %y) { +; CHECK: add.f64 fd0, fd1, fd2 +; CHECK-NEXT: ret; + %z = fadd double %x, %y + ret double %z +} + +define ptx_device i16 @t2_u16(i16 %x) { +; CHECK: add.u16 rh0, rh1, 1; +; CHECK-NEXT: ret; + %z = add i16 %x, 1 + ret i16 %z +} + +define ptx_device i32 @t2_u32(i32 %x) { +; CHECK: add.u32 r0, r1, 1; +; CHECK-NEXT: ret; %z = add i32 %x, 1 -; CHECK: ret; ret i32 %z } + +define ptx_device i64 @t2_u64(i64 %x) { +; CHECK: add.u64 rd0, rd1, 1; +; CHECK-NEXT: ret; + %z = add i64 %x, 1 + ret i64 %z +} + +define ptx_device float @t2_f32(float %x) { +; CHECK: add.f32 f0, f1, 0F3F800000; +; CHECK-NEXT: ret; + %z = fadd float %x, 1.0 + ret float %z +} + +define ptx_device double @t2_f64(double %x) { +; CHECK: add.f64 fd0, fd1, 0D3FF0000000000000; +; CHECK-NEXT: ret; + %z = fadd double %x, 1.0 + ret double %z +} diff --git a/test/CodeGen/PTX/bitwise.ll b/test/CodeGen/PTX/bitwise.ll new file mode 100644 index 000000000000..dbc77e53330b --- /dev/null +++ b/test/CodeGen/PTX/bitwise.ll @@ -0,0 +1,24 @@ +; RUN: llc < %s -march=ptx32 | FileCheck %s + +; preds + +define ptx_device i32 @t1_and_preds(i1 %x, i1 %y) { +; CHECK: and.pred p0, p1, p2 + %c = and i1 %x, %y + %d = zext i1 %c to i32 + ret i32 %d +} + +define ptx_device i32 @t1_or_preds(i1 %x, i1 %y) { +; CHECK: or.pred p0, p1, p2 + %a = or i1 %x, %y + %b = zext i1 %a to i32 + ret i32 %b +} + +define ptx_device i32 @t1_xor_preds(i1 %x, i1 %y) { +; CHECK: xor.pred p0, p1, p2 + %a = xor i1 %x, %y + %b = zext i1 %a to i32 + ret i32 %b +} diff --git a/test/CodeGen/PTX/bra.ll b/test/CodeGen/PTX/bra.ll new file mode 100644 index 000000000000..49383eb3cf96 --- /dev/null +++ b/test/CodeGen/PTX/bra.ll @@ -0,0 +1,24 @@ +; RUN: llc < %s -march=ptx32 | FileCheck %s + +define ptx_device void @test_bra_direct() { +; CHECK: bra $L__BB0_1; +entry: + br label %loop +loop: + br label %loop +} + +define ptx_device i32 @test_bra_cond_direct(i32 %x, i32 %y) { +entry: +; CHECK: setp.le.u32 p0, r1, r2 + %p = icmp ugt i32 %x, %y +; CHECK-NEXT: @p0 bra +; CHECK-NOT: bra + br i1 %p, label %clause.if, label %clause.else +clause.if: +; CHECK: mov.u32 r0, r1 + ret i32 %x +clause.else: +; CHECK: mov.u32 r0, r2 + ret i32 %y +} diff --git a/test/CodeGen/PTX/exit.ll b/test/CodeGen/PTX/exit.ll index 4071babb80ce..7816c801728f 100644 --- a/test/CodeGen/PTX/exit.ll +++ b/test/CodeGen/PTX/exit.ll @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=ptx | FileCheck %s +; RUN: llc < %s -march=ptx32 | FileCheck %s define ptx_kernel void @t1() { ; CHECK: exit; diff --git a/test/CodeGen/PTX/fdiv-sm10.ll b/test/CodeGen/PTX/fdiv-sm10.ll new file mode 100644 index 000000000000..121360ce9be3 --- /dev/null +++ b/test/CodeGen/PTX/fdiv-sm10.ll @@ -0,0 +1,15 @@ +; RUN: llc < %s -march=ptx32 -mattr=+sm10 | FileCheck %s + +define ptx_device float @t1_f32(float %x, float %y) { +; CHECK: div.approx.f32 f0, f1, f2; +; CHECK-NEXT: ret; + %a = fdiv float %x, %y + ret float %a +} + +define ptx_device double @t1_f64(double %x, double %y) { +; CHECK: div.f64 fd0, fd1, fd2; +; CHECK-NEXT: ret; + %a = fdiv double %x, %y + ret double %a +} diff --git a/test/CodeGen/PTX/fdiv-sm13.ll b/test/CodeGen/PTX/fdiv-sm13.ll new file mode 100644 index 000000000000..0ec7bae8030e --- /dev/null +++ b/test/CodeGen/PTX/fdiv-sm13.ll @@ -0,0 +1,15 @@ +; RUN: llc < %s -march=ptx32 -mattr=+sm13 | FileCheck %s + +define ptx_device float @t1_f32(float %x, float %y) { +; CHECK: div.approx.f32 f0, f1, f2; +; CHECK-NEXT: ret; + %a = fdiv float %x, %y + ret float %a +} + +define ptx_device double @t1_f64(double %x, double %y) { +; CHECK: div.rn.f64 fd0, fd1, fd2; +; CHECK-NEXT: ret; + %a = fdiv double %x, %y + ret double %a +} diff --git a/test/CodeGen/PTX/intrinsic.ll b/test/CodeGen/PTX/intrinsic.ll new file mode 100644 index 000000000000..cea41827ca47 --- /dev/null +++ b/test/CodeGen/PTX/intrinsic.ll @@ -0,0 +1,281 @@ +; RUN: llc < %s -march=ptx32 -mattr=+ptx20,+sm20 | FileCheck %s + +define ptx_device i32 @test_tid_x() { +; CHECK: mov.u32 r0, %tid.x; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.tid.x() + ret i32 %x +} + +define ptx_device i32 @test_tid_y() { +; CHECK: mov.u32 r0, %tid.y; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.tid.y() + ret i32 %x +} + +define ptx_device i32 @test_tid_z() { +; CHECK: mov.u32 r0, %tid.z; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.tid.z() + ret i32 %x +} + +define ptx_device i32 @test_tid_w() { +; CHECK: mov.u32 r0, %tid.w; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.tid.w() + ret i32 %x +} + +define ptx_device i32 @test_ntid_x() { +; CHECK: mov.u32 r0, %ntid.x; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.ntid.x() + ret i32 %x +} + +define ptx_device i32 @test_ntid_y() { +; CHECK: mov.u32 r0, %ntid.y; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.ntid.y() + ret i32 %x +} + +define ptx_device i32 @test_ntid_z() { +; CHECK: mov.u32 r0, %ntid.z; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.ntid.z() + ret i32 %x +} + +define ptx_device i32 @test_ntid_w() { +; CHECK: mov.u32 r0, %ntid.w; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.ntid.w() + ret i32 %x +} + +define ptx_device i32 @test_laneid() { +; CHECK: mov.u32 r0, %laneid; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.laneid() + ret i32 %x +} + +define ptx_device i32 @test_warpid() { +; CHECK: mov.u32 r0, %warpid; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.warpid() + ret i32 %x +} + +define ptx_device i32 @test_nwarpid() { +; CHECK: mov.u32 r0, %nwarpid; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.nwarpid() + ret i32 %x +} + +define ptx_device i32 @test_ctaid_x() { +; CHECK: mov.u32 r0, %ctaid.x; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.ctaid.x() + ret i32 %x +} + +define ptx_device i32 @test_ctaid_y() { +; CHECK: mov.u32 r0, %ctaid.y; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.ctaid.y() + ret i32 %x +} + +define ptx_device i32 @test_ctaid_z() { +; CHECK: mov.u32 r0, %ctaid.z; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.ctaid.z() + ret i32 %x +} + +define ptx_device i32 @test_ctaid_w() { +; CHECK: mov.u32 r0, %ctaid.w; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.ctaid.w() + ret i32 %x +} + +define ptx_device i32 @test_nctaid_x() { +; CHECK: mov.u32 r0, %nctaid.x; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.nctaid.x() + ret i32 %x +} + +define ptx_device i32 @test_nctaid_y() { +; CHECK: mov.u32 r0, %nctaid.y; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.nctaid.y() + ret i32 %x +} + +define ptx_device i32 @test_nctaid_z() { +; CHECK: mov.u32 r0, %nctaid.z; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.nctaid.z() + ret i32 %x +} + +define ptx_device i32 @test_nctaid_w() { +; CHECK: mov.u32 r0, %nctaid.w; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.nctaid.w() + ret i32 %x +} + +define ptx_device i32 @test_smid() { +; CHECK: mov.u32 r0, %smid; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.smid() + ret i32 %x +} + +define ptx_device i32 @test_nsmid() { +; CHECK: mov.u32 r0, %nsmid; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.nsmid() + ret i32 %x +} + +define ptx_device i32 @test_gridid() { +; CHECK: mov.u32 r0, %gridid; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.gridid() + ret i32 %x +} + +define ptx_device i32 @test_lanemask_eq() { +; CHECK: mov.u32 r0, %lanemask_eq; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.lanemask.eq() + ret i32 %x +} + +define ptx_device i32 @test_lanemask_le() { +; CHECK: mov.u32 r0, %lanemask_le; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.lanemask.le() + ret i32 %x +} + +define ptx_device i32 @test_lanemask_lt() { +; CHECK: mov.u32 r0, %lanemask_lt; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.lanemask.lt() + ret i32 %x +} + +define ptx_device i32 @test_lanemask_ge() { +; CHECK: mov.u32 r0, %lanemask_ge; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.lanemask.ge() + ret i32 %x +} + +define ptx_device i32 @test_lanemask_gt() { +; CHECK: mov.u32 r0, %lanemask_gt; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.lanemask.gt() + ret i32 %x +} + +define ptx_device i32 @test_clock() { +; CHECK: mov.u32 r0, %clock; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.clock() + ret i32 %x +} + +define ptx_device i64 @test_clock64() { +; CHECK: mov.u64 rd0, %clock64; +; CHECK-NEXT: ret; + %x = call i64 @llvm.ptx.read.clock64() + ret i64 %x +} + +define ptx_device i32 @test_pm0() { +; CHECK: mov.u32 r0, %pm0; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.pm0() + ret i32 %x +} + +define ptx_device i32 @test_pm1() { +; CHECK: mov.u32 r0, %pm1; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.pm1() + ret i32 %x +} + +define ptx_device i32 @test_pm2() { +; CHECK: mov.u32 r0, %pm2; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.pm2() + ret i32 %x +} + +define ptx_device i32 @test_pm3() { +; CHECK: mov.u32 r0, %pm3; +; CHECK-NEXT: ret; + %x = call i32 @llvm.ptx.read.pm3() + ret i32 %x +} + +define ptx_device void @test_bar_sync() { +; CHECK: bar.sync 0 +; CHECK-NEXT: ret; + call void @llvm.ptx.bar.sync(i32 0) + ret void +} + +declare i32 @llvm.ptx.read.tid.x() +declare i32 @llvm.ptx.read.tid.y() +declare i32 @llvm.ptx.read.tid.z() +declare i32 @llvm.ptx.read.tid.w() +declare i32 @llvm.ptx.read.ntid.x() +declare i32 @llvm.ptx.read.ntid.y() +declare i32 @llvm.ptx.read.ntid.z() +declare i32 @llvm.ptx.read.ntid.w() + +declare i32 @llvm.ptx.read.laneid() +declare i32 @llvm.ptx.read.warpid() +declare i32 @llvm.ptx.read.nwarpid() + +declare i32 @llvm.ptx.read.ctaid.x() +declare i32 @llvm.ptx.read.ctaid.y() +declare i32 @llvm.ptx.read.ctaid.z() +declare i32 @llvm.ptx.read.ctaid.w() +declare i32 @llvm.ptx.read.nctaid.x() +declare i32 @llvm.ptx.read.nctaid.y() +declare i32 @llvm.ptx.read.nctaid.z() +declare i32 @llvm.ptx.read.nctaid.w() + +declare i32 @llvm.ptx.read.smid() +declare i32 @llvm.ptx.read.nsmid() +declare i32 @llvm.ptx.read.gridid() + +declare i32 @llvm.ptx.read.lanemask.eq() +declare i32 @llvm.ptx.read.lanemask.le() +declare i32 @llvm.ptx.read.lanemask.lt() +declare i32 @llvm.ptx.read.lanemask.ge() +declare i32 @llvm.ptx.read.lanemask.gt() + +declare i32 @llvm.ptx.read.clock() +declare i64 @llvm.ptx.read.clock64() + +declare i32 @llvm.ptx.read.pm0() +declare i32 @llvm.ptx.read.pm1() +declare i32 @llvm.ptx.read.pm2() +declare i32 @llvm.ptx.read.pm3() + +declare void @llvm.ptx.bar.sync(i32 %i) diff --git a/test/CodeGen/PTX/ld.ll b/test/CodeGen/PTX/ld.ll index 836c4d41045a..377a95abe3db 100644 --- a/test/CodeGen/PTX/ld.ll +++ b/test/CodeGen/PTX/ld.ll @@ -1,78 +1,447 @@ -; RUN: llc < %s -march=ptx | FileCheck %s +; RUN: llc < %s -march=ptx32 | FileCheck %s -;CHECK: .extern .global .s32 array[]; -@array = external global [10 x i32] +;CHECK: .extern .global .b8 array_i16[20]; +@array_i16 = external global [10 x i16] -;CHECK: .extern .const .s32 array_constant[]; -@array_constant = external addrspace(1) constant [10 x i32] +;CHECK: .extern .const .b8 array_constant_i16[20]; +@array_constant_i16 = external addrspace(1) constant [10 x i16] -;CHECK: .extern .local .s32 array_local[]; -@array_local = external addrspace(2) global [10 x i32] +;CHECK: .extern .local .b8 array_local_i16[20]; +@array_local_i16 = external addrspace(2) global [10 x i16] -;CHECK: .extern .shared .s32 array_shared[]; -@array_shared = external addrspace(4) global [10 x i32] +;CHECK: .extern .shared .b8 array_shared_i16[20]; +@array_shared_i16 = external addrspace(4) global [10 x i16] -define ptx_device i32 @t1(i32* %p) { +;CHECK: .extern .global .b8 array_i32[40]; +@array_i32 = external global [10 x i32] + +;CHECK: .extern .const .b8 array_constant_i32[40]; +@array_constant_i32 = external addrspace(1) constant [10 x i32] + +;CHECK: .extern .local .b8 array_local_i32[40]; +@array_local_i32 = external addrspace(2) global [10 x i32] + +;CHECK: .extern .shared .b8 array_shared_i32[40]; +@array_shared_i32 = external addrspace(4) global [10 x i32] + +;CHECK: .extern .global .b8 array_i64[80]; +@array_i64 = external global [10 x i64] + +;CHECK: .extern .const .b8 array_constant_i64[80]; +@array_constant_i64 = external addrspace(1) constant [10 x i64] + +;CHECK: .extern .local .b8 array_local_i64[80]; +@array_local_i64 = external addrspace(2) global [10 x i64] + +;CHECK: .extern .shared .b8 array_shared_i64[80]; +@array_shared_i64 = external addrspace(4) global [10 x i64] + +;CHECK: .extern .global .b8 array_float[40]; +@array_float = external global [10 x float] + +;CHECK: .extern .const .b8 array_constant_float[40]; +@array_constant_float = external addrspace(1) constant [10 x float] + +;CHECK: .extern .local .b8 array_local_float[40]; +@array_local_float = external addrspace(2) global [10 x float] + +;CHECK: .extern .shared .b8 array_shared_float[40]; +@array_shared_float = external addrspace(4) global [10 x float] + +;CHECK: .extern .global .b8 array_double[80]; +@array_double = external global [10 x double] + +;CHECK: .extern .const .b8 array_constant_double[80]; +@array_constant_double = external addrspace(1) constant [10 x double] + +;CHECK: .extern .local .b8 array_local_double[80]; +@array_local_double = external addrspace(2) global [10 x double] + +;CHECK: .extern .shared .b8 array_shared_double[80]; +@array_shared_double = external addrspace(4) global [10 x double] + + +define ptx_device i16 @t1_u16(i16* %p) { entry: -;CHECK: ld.global.s32 r0, [r1]; +;CHECK: ld.global.u16 rh0, [r1]; +;CHECK-NEXT: ret; + %x = load i16* %p + ret i16 %x +} + +define ptx_device i32 @t1_u32(i32* %p) { +entry: +;CHECK: ld.global.u32 r0, [r1]; +;CHECK-NEXT: ret; %x = load i32* %p ret i32 %x } -define ptx_device i32 @t2(i32* %p) { +define ptx_device i64 @t1_u64(i64* %p) { +entry: +;CHECK: ld.global.u64 rd0, [r1]; +;CHECK-NEXT: ret; + %x = load i64* %p + ret i64 %x +} + +define ptx_device float @t1_f32(float* %p) { +entry: +;CHECK: ld.global.f32 f0, [r1]; +;CHECK-NEXT: ret; + %x = load float* %p + ret float %x +} + +define ptx_device double @t1_f64(double* %p) { +entry: +;CHECK: ld.global.f64 fd0, [r1]; +;CHECK-NEXT: ret; + %x = load double* %p + ret double %x +} + +define ptx_device i16 @t2_u16(i16* %p) { entry: -;CHECK: ld.global.s32 r0, [r1+4]; +;CHECK: ld.global.u16 rh0, [r1+2]; +;CHECK-NEXT: ret; + %i = getelementptr i16* %p, i32 1 + %x = load i16* %i + ret i16 %x +} + +define ptx_device i32 @t2_u32(i32* %p) { +entry: +;CHECK: ld.global.u32 r0, [r1+4]; +;CHECK-NEXT: ret; %i = getelementptr i32* %p, i32 1 %x = load i32* %i ret i32 %x } -define ptx_device i32 @t3(i32* %p, i32 %q) { +define ptx_device i64 @t2_u64(i64* %p) { +entry: +;CHECK: ld.global.u64 rd0, [r1+8]; +;CHECK-NEXT: ret; + %i = getelementptr i64* %p, i32 1 + %x = load i64* %i + ret i64 %x +} + +define ptx_device float @t2_f32(float* %p) { +entry: +;CHECK: ld.global.f32 f0, [r1+4]; +;CHECK-NEXT: ret; + %i = getelementptr float* %p, i32 1 + %x = load float* %i + ret float %x +} + +define ptx_device double @t2_f64(double* %p) { +entry: +;CHECK: ld.global.f64 fd0, [r1+8]; +;CHECK-NEXT: ret; + %i = getelementptr double* %p, i32 1 + %x = load double* %i + ret double %x +} + +define ptx_device i16 @t3_u16(i16* %p, i32 %q) { +entry: +;CHECK: shl.b32 r0, r2, 1; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: ld.global.u16 rh0, [r0]; + %i = getelementptr i16* %p, i32 %q + %x = load i16* %i + ret i16 %x +} + +define ptx_device i32 @t3_u32(i32* %p, i32 %q) { entry: ;CHECK: shl.b32 r0, r2, 2; -;CHECK: add.s32 r0, r1, r0; -;CHECK: ld.global.s32 r0, [r0]; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: ld.global.u32 r0, [r0]; %i = getelementptr i32* %p, i32 %q %x = load i32* %i ret i32 %x } -define ptx_device i32 @t4_global() { +define ptx_device i64 @t3_u64(i64* %p, i32 %q) { +entry: +;CHECK: shl.b32 r0, r2, 3; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: ld.global.u64 rd0, [r0]; + %i = getelementptr i64* %p, i32 %q + %x = load i64* %i + ret i64 %x +} + +define ptx_device float @t3_f32(float* %p, i32 %q) { +entry: +;CHECK: shl.b32 r0, r2, 2; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: ld.global.f32 f0, [r0]; + %i = getelementptr float* %p, i32 %q + %x = load float* %i + ret float %x +} + +define ptx_device double @t3_f64(double* %p, i32 %q) { +entry: +;CHECK: shl.b32 r0, r2, 3; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: ld.global.f64 fd0, [r0]; + %i = getelementptr double* %p, i32 %q + %x = load double* %i + ret double %x +} + +define ptx_device i16 @t4_global_u16() { +entry: +;CHECK: mov.u32 r0, array_i16; +;CHECK-NEXT: ld.global.u16 rh0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16]* @array_i16, i32 0, i32 0 + %x = load i16* %i + ret i16 %x +} + +define ptx_device i32 @t4_global_u32() { entry: -;CHECK: ld.global.s32 r0, [array]; - %i = getelementptr [10 x i32]* @array, i32 0, i32 0 +;CHECK: mov.u32 r0, array_i32; +;CHECK-NEXT: ld.global.u32 r0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32]* @array_i32, i32 0, i32 0 %x = load i32* %i ret i32 %x } -define ptx_device i32 @t4_const() { +define ptx_device i64 @t4_global_u64() { entry: -;CHECK: ld.const.s32 r0, [array_constant]; - %i = getelementptr [10 x i32] addrspace(1)* @array_constant, i32 0, i32 0 +;CHECK: mov.u32 r0, array_i64; +;CHECK-NEXT: ld.global.u64 rd0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64]* @array_i64, i32 0, i32 0 + %x = load i64* %i + ret i64 %x +} + +define ptx_device float @t4_global_f32() { +entry: +;CHECK: mov.u32 r0, array_float; +;CHECK-NEXT: ld.global.f32 f0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array_float, i32 0, i32 0 + %x = load float* %i + ret float %x +} + +define ptx_device double @t4_global_f64() { +entry: +;CHECK: mov.u32 r0, array_double; +;CHECK-NEXT: ld.global.f64 fd0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double]* @array_double, i32 0, i32 0 + %x = load double* %i + ret double %x +} + +define ptx_device i16 @t4_const_u16() { +entry: +;CHECK: mov.u32 r0, array_constant_i16; +;CHECK-NEXT: ld.const.u16 rh0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16] addrspace(1)* @array_constant_i16, i32 0, i32 0 + %x = load i16 addrspace(1)* %i + ret i16 %x +} + +define ptx_device i32 @t4_const_u32() { +entry: +;CHECK: mov.u32 r0, array_constant_i32; +;CHECK-NEXT: ld.const.u32 r0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32] addrspace(1)* @array_constant_i32, i32 0, i32 0 %x = load i32 addrspace(1)* %i ret i32 %x } -define ptx_device i32 @t4_local() { +define ptx_device i64 @t4_const_u64() { +entry: +;CHECK: mov.u32 r0, array_constant_i64; +;CHECK-NEXT: ld.const.u64 rd0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64] addrspace(1)* @array_constant_i64, i32 0, i32 0 + %x = load i64 addrspace(1)* %i + ret i64 %x +} + +define ptx_device float @t4_const_f32() { entry: -;CHECK: ld.local.s32 r0, [array_local]; - %i = getelementptr [10 x i32] addrspace(2)* @array_local, i32 0, i32 0 +;CHECK: mov.u32 r0, array_constant_float; +;CHECK-NEXT: ld.const.f32 f0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(1)* @array_constant_float, i32 0, i32 0 + %x = load float addrspace(1)* %i + ret float %x +} + +define ptx_device double @t4_const_f64() { +entry: +;CHECK: mov.u32 r0, array_constant_double; +;CHECK-NEXT: ld.const.f64 fd0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double] addrspace(1)* @array_constant_double, i32 0, i32 0 + %x = load double addrspace(1)* %i + ret double %x +} + +define ptx_device i16 @t4_local_u16() { +entry: +;CHECK: mov.u32 r0, array_local_i16; +;CHECK-NEXT: ld.local.u16 rh0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16] addrspace(2)* @array_local_i16, i32 0, i32 0 + %x = load i16 addrspace(2)* %i + ret i16 %x +} + +define ptx_device i32 @t4_local_u32() { +entry: +;CHECK: mov.u32 r0, array_local_i32; +;CHECK-NEXT: ld.local.u32 r0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32] addrspace(2)* @array_local_i32, i32 0, i32 0 %x = load i32 addrspace(2)* %i ret i32 %x } -define ptx_device i32 @t4_shared() { +define ptx_device i64 @t4_local_u64() { entry: -;CHECK: ld.shared.s32 r0, [array_shared]; - %i = getelementptr [10 x i32] addrspace(4)* @array_shared, i32 0, i32 0 +;CHECK: mov.u32 r0, array_local_i64; +;CHECK-NEXT: ld.local.u64 rd0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64] addrspace(2)* @array_local_i64, i32 0, i32 0 + %x = load i64 addrspace(2)* %i + ret i64 %x +} + +define ptx_device float @t4_local_f32() { +entry: +;CHECK: mov.u32 r0, array_local_float; +;CHECK-NEXT: ld.local.f32 f0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(2)* @array_local_float, i32 0, i32 0 + %x = load float addrspace(2)* %i + ret float %x +} + +define ptx_device double @t4_local_f64() { +entry: +;CHECK: mov.u32 r0, array_local_double; +;CHECK-NEXT: ld.local.f64 fd0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double] addrspace(2)* @array_local_double, i32 0, i32 0 + %x = load double addrspace(2)* %i + ret double %x +} + +define ptx_device i16 @t4_shared_u16() { +entry: +;CHECK: mov.u32 r0, array_shared_i16; +;CHECK-NEXT: ld.shared.u16 rh0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16] addrspace(4)* @array_shared_i16, i32 0, i32 0 + %x = load i16 addrspace(4)* %i + ret i16 %x +} + +define ptx_device i32 @t4_shared_u32() { +entry: +;CHECK: mov.u32 r0, array_shared_i32; +;CHECK-NEXT: ld.shared.u32 r0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32] addrspace(4)* @array_shared_i32, i32 0, i32 0 %x = load i32 addrspace(4)* %i ret i32 %x } -define ptx_device i32 @t5() { +define ptx_device i64 @t4_shared_u64() { +entry: +;CHECK: mov.u32 r0, array_shared_i64; +;CHECK-NEXT: ld.shared.u64 rd0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64] addrspace(4)* @array_shared_i64, i32 0, i32 0 + %x = load i64 addrspace(4)* %i + ret i64 %x +} + +define ptx_device float @t4_shared_f32() { +entry: +;CHECK: mov.u32 r0, array_shared_float; +;CHECK-NEXT: ld.shared.f32 f0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(4)* @array_shared_float, i32 0, i32 0 + %x = load float addrspace(4)* %i + ret float %x +} + +define ptx_device double @t4_shared_f64() { +entry: +;CHECK: mov.u32 r0, array_shared_double; +;CHECK-NEXT: ld.shared.f64 fd0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double] addrspace(4)* @array_shared_double, i32 0, i32 0 + %x = load double addrspace(4)* %i + ret double %x +} + +define ptx_device i16 @t5_u16() { entry: -;CHECK: ld.global.s32 r0, [array+4]; - %i = getelementptr [10 x i32]* @array, i32 0, i32 1 +;CHECK: mov.u32 r0, array_i16; +;CHECK-NEXT: ld.global.u16 rh0, [r0+2]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16]* @array_i16, i32 0, i32 1 + %x = load i16* %i + ret i16 %x +} + +define ptx_device i32 @t5_u32() { +entry: +;CHECK: mov.u32 r0, array_i32; +;CHECK-NEXT: ld.global.u32 r0, [r0+4]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32]* @array_i32, i32 0, i32 1 %x = load i32* %i ret i32 %x } + +define ptx_device i64 @t5_u64() { +entry: +;CHECK: mov.u32 r0, array_i64; +;CHECK-NEXT: ld.global.u64 rd0, [r0+8]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64]* @array_i64, i32 0, i32 1 + %x = load i64* %i + ret i64 %x +} + +define ptx_device float @t5_f32() { +entry: +;CHECK: mov.u32 r0, array_float; +;CHECK-NEXT: ld.global.f32 f0, [r0+4]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array_float, i32 0, i32 1 + %x = load float* %i + ret float %x +} + +define ptx_device double @t5_f64() { +entry: +;CHECK: mov.u32 r0, array_double; +;CHECK-NEXT: ld.global.f64 fd0, [r0+8]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double]* @array_double, i32 0, i32 1 + %x = load double* %i + ret double %x +} diff --git a/test/CodeGen/PTX/llvm-intrinsic.ll b/test/CodeGen/PTX/llvm-intrinsic.ll new file mode 100644 index 000000000000..1e265f5b7b3a --- /dev/null +++ b/test/CodeGen/PTX/llvm-intrinsic.ll @@ -0,0 +1,56 @@ +; RUN: llc < %s -march=ptx32 -mattr=+ptx20,+sm20 | FileCheck %s + +define ptx_device float @test_sqrt_f32(float %x) { +entry: +; CHECK: sqrt.rn.f32 f0, f1; +; CHECK-NEXT: ret; + %y = call float @llvm.sqrt.f32(float %x) + ret float %y +} + +define ptx_device double @test_sqrt_f64(double %x) { +entry: +; CHECK: sqrt.rn.f64 fd0, fd1; +; CHECK-NEXT: ret; + %y = call double @llvm.sqrt.f64(double %x) + ret double %y +} + +define ptx_device float @test_sin_f32(float %x) { +entry: +; CHECK: sin.approx.f32 f0, f1; +; CHECK-NEXT: ret; + %y = call float @llvm.sin.f32(float %x) + ret float %y +} + +define ptx_device double @test_sin_f64(double %x) { +entry: +; CHECK: sin.approx.f64 fd0, fd1; +; CHECK-NEXT: ret; + %y = call double @llvm.sin.f64(double %x) + ret double %y +} + +define ptx_device float @test_cos_f32(float %x) { +entry: +; CHECK: cos.approx.f32 f0, f1; +; CHECK-NEXT: ret; + %y = call float @llvm.cos.f32(float %x) + ret float %y +} + +define ptx_device double @test_cos_f64(double %x) { +entry: +; CHECK: cos.approx.f64 fd0, fd1; +; CHECK-NEXT: ret; + %y = call double @llvm.cos.f64(double %x) + ret double %y +} + +declare float @llvm.sqrt.f32(float) +declare double @llvm.sqrt.f64(double) +declare float @llvm.sin.f32(float) +declare double @llvm.sin.f64(double) +declare float @llvm.cos.f32(float) +declare double @llvm.cos.f64(double) diff --git a/test/CodeGen/PTX/mad.ll b/test/CodeGen/PTX/mad.ll new file mode 100644 index 000000000000..0c25f2c0030a --- /dev/null +++ b/test/CodeGen/PTX/mad.ll @@ -0,0 +1,17 @@ +; RUN: llc < %s -march=ptx32 -mattr=+sm13 | FileCheck %s + +define ptx_device float @t1_f32(float %x, float %y, float %z) { +; CHECK: mad.rn.f32 f0, f1, f2, f3; +; CHECK-NEXT: ret; + %a = fmul float %x, %y + %b = fadd float %a, %z + ret float %b +} + +define ptx_device double @t1_f64(double %x, double %y, double %z) { +; CHECK: mad.rn.f64 fd0, fd1, fd2, fd3; +; CHECK-NEXT: ret; + %a = fmul double %x, %y + %b = fadd double %a, %z + ret double %b +} diff --git a/test/CodeGen/PTX/mov.ll b/test/CodeGen/PTX/mov.ll index c365e9beb897..120572a0e868 100644 --- a/test/CodeGen/PTX/mov.ll +++ b/test/CodeGen/PTX/mov.ll @@ -1,13 +1,62 @@ -; RUN: llc < %s -march=ptx | FileCheck %s +; RUN: llc < %s -march=ptx32 | FileCheck %s -define ptx_device i32 @t1() { -; CHECK: mov.s32 r0, 0; +define ptx_device i16 @t1_u16() { +; CHECK: mov.u16 rh0, 0; +; CHECK: ret; + ret i16 0 +} + +define ptx_device i32 @t1_u32() { +; CHECK: mov.u32 r0, 0; ; CHECK: ret; ret i32 0 } -define ptx_device i32 @t2(i32 %x) { -; CHECK: mov.s32 r0, r1; +define ptx_device i64 @t1_u64() { +; CHECK: mov.u64 rd0, 0; +; CHECK: ret; + ret i64 0 +} + +define ptx_device float @t1_f32() { +; CHECK: mov.f32 f0, 0F00000000; +; CHECK: ret; + ret float 0.0 +} + +define ptx_device double @t1_f64() { +; CHECK: mov.f64 fd0, 0D0000000000000000; +; CHECK: ret; + ret double 0.0 +} + +define ptx_device i16 @t2_u16(i16 %x) { +; CHECK: mov.u16 rh0, rh1; +; CHECK: ret; + ret i16 %x +} + +define ptx_device i32 @t2_u32(i32 %x) { +; CHECK: mov.u32 r0, r1; ; CHECK: ret; ret i32 %x } + +define ptx_device i64 @t2_u64(i64 %x) { +; CHECK: mov.u64 rd0, rd1; +; CHECK: ret; + ret i64 %x +} + +define ptx_device float @t3_f32(float %x) { +; CHECK: mov.f32 f0, f1; +; CHECK-NEXT: ret; + ret float %x +} + +define ptx_device double @t3_f64(double %x) { +; CHECK: mov.f64 fd0, fd1; +; CHECK-NEXT: ret; + ret double %x +} + diff --git a/test/CodeGen/PTX/mul.ll b/test/CodeGen/PTX/mul.ll new file mode 100644 index 000000000000..5ce042675dc8 --- /dev/null +++ b/test/CodeGen/PTX/mul.ll @@ -0,0 +1,39 @@ +; RUN: llc < %s -march=ptx32 | FileCheck %s + +;define ptx_device i32 @t1(i32 %x, i32 %y) { +; %z = mul i32 %x, %y +; ret i32 %z +;} + +;define ptx_device i32 @t2(i32 %x) { +; %z = mul i32 %x, 1 +; ret i32 %z +;} + +define ptx_device float @t1_f32(float %x, float %y) { +; CHECK: mul.f32 f0, f1, f2 +; CHECK-NEXT: ret; + %z = fmul float %x, %y + ret float %z +} + +define ptx_device double @t1_f64(double %x, double %y) { +; CHECK: mul.f64 fd0, fd1, fd2 +; CHECK-NEXT: ret; + %z = fmul double %x, %y + ret double %z +} + +define ptx_device float @t2_f32(float %x) { +; CHECK: mul.f32 f0, f1, 0F40A00000; +; CHECK-NEXT: ret; + %z = fmul float %x, 5.0 + ret float %z +} + +define ptx_device double @t2_f64(double %x) { +; CHECK: mul.f64 fd0, fd1, 0D4014000000000000; +; CHECK-NEXT: ret; + %z = fmul double %x, 5.0 + ret double %z +} diff --git a/test/CodeGen/PTX/options.ll b/test/CodeGen/PTX/options.ll index a14d5c9c27ba..ac33fef0d6e3 100644 --- a/test/CodeGen/PTX/options.ll +++ b/test/CodeGen/PTX/options.ll @@ -1,5 +1,9 @@ -; RUN: llc < %s -march=ptx -ptx-version=2.0 | grep ".version 2.0" -; RUN: llc < %s -march=ptx -ptx-target=sm_20 | grep ".target sm_20" +; RUN: llc < %s -march=ptx32 -mattr=ptx20 | grep ".version 2.0" +; RUN: llc < %s -march=ptx32 -mattr=ptx21 | grep ".version 2.1" +; RUN: llc < %s -march=ptx32 -mattr=ptx22 | grep ".version 2.2" +; RUN: llc < %s -march=ptx32 -mattr=sm10 | grep ".target sm_10" +; RUN: llc < %s -march=ptx32 -mattr=sm13 | grep ".target sm_13" +; RUN: llc < %s -march=ptx32 -mattr=sm20 | grep ".target sm_20" define ptx_device void @t1() { ret void diff --git a/test/CodeGen/PTX/parameter-order.ll b/test/CodeGen/PTX/parameter-order.ll new file mode 100644 index 000000000000..95d4a328149c --- /dev/null +++ b/test/CodeGen/PTX/parameter-order.ll @@ -0,0 +1,8 @@ +; RUN: llc < %s -march=ptx32 | FileCheck %s + +; CHECK: .func (.reg .u32 r0) test_parameter_order (.reg .f32 f1, .reg .u32 r1, .reg .u32 r2, .reg .f32 f2) +define ptx_device i32 @test_parameter_order(float %a, i32 %b, i32 %c, float %d) { +; CHECK: sub.u32 r0, r1, r2 + %result = sub i32 %b, %c + ret i32 %result +} diff --git a/test/CodeGen/PTX/ret.ll b/test/CodeGen/PTX/ret.ll index d5037f25fd36..ba0523f6424a 100644 --- a/test/CodeGen/PTX/ret.ll +++ b/test/CodeGen/PTX/ret.ll @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=ptx | FileCheck %s +; RUN: llc < %s -march=ptx32 | FileCheck %s define ptx_device void @t1() { ; CHECK: ret; diff --git a/test/CodeGen/PTX/setp.ll b/test/CodeGen/PTX/setp.ll new file mode 100644 index 000000000000..5836122049e6 --- /dev/null +++ b/test/CodeGen/PTX/setp.ll @@ -0,0 +1,134 @@ +; RUN: llc < %s -march=ptx32 | FileCheck %s + +define ptx_device i32 @test_setp_eq_u32_rr(i32 %x, i32 %y) { +; CHECK: setp.eq.u32 p0, r1, r2; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp eq i32 %x, %y + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_ne_u32_rr(i32 %x, i32 %y) { +; CHECK: setp.ne.u32 p0, r1, r2; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp ne i32 %x, %y + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_lt_u32_rr(i32 %x, i32 %y) { +; CHECK: setp.lt.u32 p0, r1, r2; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp ult i32 %x, %y + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_le_u32_rr(i32 %x, i32 %y) { +; CHECK: setp.le.u32 p0, r1, r2; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp ule i32 %x, %y + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_gt_u32_rr(i32 %x, i32 %y) { +; CHECK: setp.gt.u32 p0, r1, r2; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp ugt i32 %x, %y + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_ge_u32_rr(i32 %x, i32 %y) { +; CHECK: setp.ge.u32 p0, r1, r2; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp uge i32 %x, %y + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_eq_u32_ri(i32 %x) { +; CHECK: setp.eq.u32 p0, r1, 1; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp eq i32 %x, 1 + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_ne_u32_ri(i32 %x) { +; CHECK: setp.ne.u32 p0, r1, 1; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp ne i32 %x, 1 + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_lt_u32_ri(i32 %x) { +; CHECK: setp.eq.u32 p0, r1, 0; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp ult i32 %x, 1 + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_le_u32_ri(i32 %x) { +; CHECK: setp.lt.u32 p0, r1, 2; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp ule i32 %x, 1 + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_gt_u32_ri(i32 %x) { +; CHECK: setp.gt.u32 p0, r1, 1; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp ugt i32 %x, 1 + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_ge_u32_ri(i32 %x) { +; CHECK: setp.ne.u32 p0, r1, 0; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %p = icmp uge i32 %x, 1 + %z = zext i1 %p to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_4_op_format_1(i32 %x, i32 %y, i32 %u, i32 %v) { +; CHECK: setp.gt.u32 p0, r3, r4; +; CHECK-NEXT: setp.eq.and.u32 p0, r1, r2, p0; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %c = icmp eq i32 %x, %y + %d = icmp ugt i32 %u, %v + %e = and i1 %c, %d + %z = zext i1 %e to i32 + ret i32 %z +} + +define ptx_device i32 @test_setp_4_op_format_2(i32 %x, i32 %y, i32 %w) { +; CHECK: cvt.pred.u32 p0, r3; +; CHECK-NEXT: setp.eq.and.u32 p0, r1, r2, !p0; +; CHECK-NEXT: cvt.u32.pred r0, p0; +; CHECK-NEXT: ret; + %c = trunc i32 %w to i1 + %d = icmp eq i32 %x, %y + %e = xor i1 %c, 1 + %f = and i1 %d, %e + %z = zext i1 %f to i32 + ret i32 %z +} diff --git a/test/CodeGen/PTX/shl.ll b/test/CodeGen/PTX/shl.ll index b564b43ab932..6e72c9221325 100644 --- a/test/CodeGen/PTX/shl.ll +++ b/test/CodeGen/PTX/shl.ll @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=ptx | FileCheck %s +; RUN: llc < %s -march=ptx32 | FileCheck %s define ptx_device i32 @t1(i32 %x, i32 %y) { ; CHECK: shl.b32 r0, r1, r2 diff --git a/test/CodeGen/PTX/shr.ll b/test/CodeGen/PTX/shr.ll index 3f8ade862b75..8693e0ecf49a 100644 --- a/test/CodeGen/PTX/shr.ll +++ b/test/CodeGen/PTX/shr.ll @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=ptx | FileCheck %s +; RUN: llc < %s -march=ptx32 | FileCheck %s define ptx_device i32 @t1(i32 %x, i32 %y) { ; CHECK: shr.u32 r0, r1, r2 diff --git a/test/CodeGen/PTX/st.ll b/test/CodeGen/PTX/st.ll index 2cbacb9ee59c..dee5c61abe66 100644 --- a/test/CodeGen/PTX/st.ll +++ b/test/CodeGen/PTX/st.ll @@ -1,71 +1,402 @@ -; RUN: llc < %s -march=ptx | FileCheck %s +; RUN: llc < %s -march=ptx32 | FileCheck %s -;CHECK: .extern .global .s32 array[]; -@array = external global [10 x i32] +;CHECK: .extern .global .b8 array_i16[20]; +@array_i16 = external global [10 x i16] -;CHECK: .extern .const .s32 array_constant[]; -@array_constant = external addrspace(1) constant [10 x i32] +;CHECK: .extern .const .b8 array_constant_i16[20]; +@array_constant_i16 = external addrspace(1) constant [10 x i16] -;CHECK: .extern .local .s32 array_local[]; -@array_local = external addrspace(2) global [10 x i32] +;CHECK: .extern .local .b8 array_local_i16[20]; +@array_local_i16 = external addrspace(2) global [10 x i16] -;CHECK: .extern .shared .s32 array_shared[]; -@array_shared = external addrspace(4) global [10 x i32] +;CHECK: .extern .shared .b8 array_shared_i16[20]; +@array_shared_i16 = external addrspace(4) global [10 x i16] -define ptx_device void @t1(i32* %p, i32 %x) { +;CHECK: .extern .global .b8 array_i32[40]; +@array_i32 = external global [10 x i32] + +;CHECK: .extern .const .b8 array_constant_i32[40]; +@array_constant_i32 = external addrspace(1) constant [10 x i32] + +;CHECK: .extern .local .b8 array_local_i32[40]; +@array_local_i32 = external addrspace(2) global [10 x i32] + +;CHECK: .extern .shared .b8 array_shared_i32[40]; +@array_shared_i32 = external addrspace(4) global [10 x i32] + +;CHECK: .extern .global .b8 array_i64[80]; +@array_i64 = external global [10 x i64] + +;CHECK: .extern .const .b8 array_constant_i64[80]; +@array_constant_i64 = external addrspace(1) constant [10 x i64] + +;CHECK: .extern .local .b8 array_local_i64[80]; +@array_local_i64 = external addrspace(2) global [10 x i64] + +;CHECK: .extern .shared .b8 array_shared_i64[80]; +@array_shared_i64 = external addrspace(4) global [10 x i64] + +;CHECK: .extern .global .b8 array_float[40]; +@array_float = external global [10 x float] + +;CHECK: .extern .const .b8 array_constant_float[40]; +@array_constant_float = external addrspace(1) constant [10 x float] + +;CHECK: .extern .local .b8 array_local_float[40]; +@array_local_float = external addrspace(2) global [10 x float] + +;CHECK: .extern .shared .b8 array_shared_float[40]; +@array_shared_float = external addrspace(4) global [10 x float] + +;CHECK: .extern .global .b8 array_double[80]; +@array_double = external global [10 x double] + +;CHECK: .extern .const .b8 array_constant_double[80]; +@array_constant_double = external addrspace(1) constant [10 x double] + +;CHECK: .extern .local .b8 array_local_double[80]; +@array_local_double = external addrspace(2) global [10 x double] + +;CHECK: .extern .shared .b8 array_shared_double[80]; +@array_shared_double = external addrspace(4) global [10 x double] + + +define ptx_device void @t1_u16(i16* %p, i16 %x) { entry: -;CHECK: st.global.s32 [r1], r2; +;CHECK: st.global.u16 [r1], rh1; +;CHECK-NEXT: ret; + store i16 %x, i16* %p + ret void +} + +define ptx_device void @t1_u32(i32* %p, i32 %x) { +entry: +;CHECK: st.global.u32 [r1], r2; +;CHECK-NEXT: ret; store i32 %x, i32* %p ret void } -define ptx_device void @t2(i32* %p, i32 %x) { +define ptx_device void @t1_u64(i64* %p, i64 %x) { +entry: +;CHECK: st.global.u64 [r1], rd1; +;CHECK-NEXT: ret; + store i64 %x, i64* %p + ret void +} + +define ptx_device void @t1_f32(float* %p, float %x) { +entry: +;CHECK: st.global.f32 [r1], f1; +;CHECK-NEXT: ret; + store float %x, float* %p + ret void +} + +define ptx_device void @t1_f64(double* %p, double %x) { +entry: +;CHECK: st.global.f64 [r1], fd1; +;CHECK-NEXT: ret; + store double %x, double* %p + ret void +} + +define ptx_device void @t2_u16(i16* %p, i16 %x) { entry: -;CHECK: st.global.s32 [r1+4], r2; +;CHECK: st.global.u16 [r1+2], rh1; +;CHECK-NEXT: ret; + %i = getelementptr i16* %p, i32 1 + store i16 %x, i16* %i + ret void +} + +define ptx_device void @t2_u32(i32* %p, i32 %x) { +entry: +;CHECK: st.global.u32 [r1+4], r2; +;CHECK-NEXT: ret; %i = getelementptr i32* %p, i32 1 store i32 %x, i32* %i ret void } -define ptx_device void @t3(i32* %p, i32 %q, i32 %x) { -;CHECK: .reg .s32 r0; +define ptx_device void @t2_u64(i64* %p, i64 %x) { +entry: +;CHECK: st.global.u64 [r1+8], rd1; +;CHECK-NEXT: ret; + %i = getelementptr i64* %p, i32 1 + store i64 %x, i64* %i + ret void +} + +define ptx_device void @t2_f32(float* %p, float %x) { +entry: +;CHECK: st.global.f32 [r1+4], f1; +;CHECK-NEXT: ret; + %i = getelementptr float* %p, i32 1 + store float %x, float* %i + ret void +} + +define ptx_device void @t2_f64(double* %p, double %x) { +entry: +;CHECK: st.global.f64 [r1+8], fd1; +;CHECK-NEXT: ret; + %i = getelementptr double* %p, i32 1 + store double %x, double* %i + ret void +} + +define ptx_device void @t3_u16(i16* %p, i32 %q, i16 %x) { +entry: +;CHECK: shl.b32 r0, r2, 1; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: st.global.u16 [r0], rh1; +;CHECK-NEXT: ret; + %i = getelementptr i16* %p, i32 %q + store i16 %x, i16* %i + ret void +} + +define ptx_device void @t3_u32(i32* %p, i32 %q, i32 %x) { entry: ;CHECK: shl.b32 r0, r2, 2; -;CHECK: add.s32 r0, r1, r0; -;CHECK: st.global.s32 [r0], r3; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: st.global.u32 [r0], r3; +;CHECK-NEXT: ret; %i = getelementptr i32* %p, i32 %q store i32 %x, i32* %i ret void } -define ptx_device void @t4_global(i32 %x) { +define ptx_device void @t3_u64(i64* %p, i32 %q, i64 %x) { +entry: +;CHECK: shl.b32 r0, r2, 3; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: st.global.u64 [r0], rd1; +;CHECK-NEXT: ret; + %i = getelementptr i64* %p, i32 %q + store i64 %x, i64* %i + ret void +} + +define ptx_device void @t3_f32(float* %p, i32 %q, float %x) { +entry: +;CHECK: shl.b32 r0, r2, 2; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: st.global.f32 [r0], f1; +;CHECK-NEXT: ret; + %i = getelementptr float* %p, i32 %q + store float %x, float* %i + ret void +} + +define ptx_device void @t3_f64(double* %p, i32 %q, double %x) { +entry: +;CHECK: shl.b32 r0, r2, 3; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: st.global.f64 [r0], fd1; +;CHECK-NEXT: ret; + %i = getelementptr double* %p, i32 %q + store double %x, double* %i + ret void +} + +define ptx_device void @t4_global_u16(i16 %x) { +entry: +;CHECK: mov.u32 r0, array_i16; +;CHECK-NEXT: st.global.u16 [r0], rh1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16]* @array_i16, i16 0, i16 0 + store i16 %x, i16* %i + ret void +} + +define ptx_device void @t4_global_u32(i32 %x) { entry: -;CHECK: st.global.s32 [array], r1; - %i = getelementptr [10 x i32]* @array, i32 0, i32 0 +;CHECK: mov.u32 r0, array_i32; +;CHECK-NEXT: st.global.u32 [r0], r1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32]* @array_i32, i32 0, i32 0 store i32 %x, i32* %i ret void } -define ptx_device void @t4_local(i32 %x) { +define ptx_device void @t4_global_u64(i64 %x) { +entry: +;CHECK: mov.u32 r0, array_i64; +;CHECK-NEXT: st.global.u64 [r0], rd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64]* @array_i64, i32 0, i32 0 + store i64 %x, i64* %i + ret void +} + +define ptx_device void @t4_global_f32(float %x) { +entry: +;CHECK: mov.u32 r0, array_float; +;CHECK-NEXT: st.global.f32 [r0], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array_float, i32 0, i32 0 + store float %x, float* %i + ret void +} + +define ptx_device void @t4_global_f64(double %x) { +entry: +;CHECK: mov.u32 r0, array_double; +;CHECK-NEXT: st.global.f64 [r0], fd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double]* @array_double, i32 0, i32 0 + store double %x, double* %i + ret void +} + +define ptx_device void @t4_local_u16(i16 %x) { entry: -;CHECK: st.local.s32 [array_local], r1; - %i = getelementptr [10 x i32] addrspace(2)* @array_local, i32 0, i32 0 +;CHECK: mov.u32 r0, array_local_i16; +;CHECK-NEXT: st.local.u16 [r0], rh1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16] addrspace(2)* @array_local_i16, i32 0, i32 0 + store i16 %x, i16 addrspace(2)* %i + ret void +} + +define ptx_device void @t4_local_u32(i32 %x) { +entry: +;CHECK: mov.u32 r0, array_local_i32; +;CHECK-NEXT: st.local.u32 [r0], r1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32] addrspace(2)* @array_local_i32, i32 0, i32 0 store i32 %x, i32 addrspace(2)* %i ret void } -define ptx_device void @t4_shared(i32 %x) { +define ptx_device void @t4_local_u64(i64 %x) { +entry: +;CHECK: mov.u32 r0, array_local_i64; +;CHECK-NEXT: st.local.u64 [r0], rd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64] addrspace(2)* @array_local_i64, i32 0, i32 0 + store i64 %x, i64 addrspace(2)* %i + ret void +} + +define ptx_device void @t4_local_f32(float %x) { +entry: +;CHECK: mov.u32 r0, array_local_float; +;CHECK-NEXT: st.local.f32 [r0], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(2)* @array_local_float, i32 0, i32 0 + store float %x, float addrspace(2)* %i + ret void +} + +define ptx_device void @t4_local_f64(double %x) { +entry: +;CHECK: mov.u32 r0, array_local_double; +;CHECK-NEXT: st.local.f64 [r0], fd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double] addrspace(2)* @array_local_double, i32 0, i32 0 + store double %x, double addrspace(2)* %i + ret void +} + +define ptx_device void @t4_shared_u16(i16 %x) { entry: -;CHECK: st.shared.s32 [array_shared], r1; - %i = getelementptr [10 x i32] addrspace(4)* @array_shared, i32 0, i32 0 +;CHECK: mov.u32 r0, array_shared_i16; +;CHECK-NEXT: st.shared.u16 [r0], rh1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16] addrspace(4)* @array_shared_i16, i32 0, i32 0 + store i16 %x, i16 addrspace(4)* %i + ret void +} + +define ptx_device void @t4_shared_u32(i32 %x) { +entry: +;CHECK: mov.u32 r0, array_shared_i32; +;CHECK-NEXT: st.shared.u32 [r0], r1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32] addrspace(4)* @array_shared_i32, i32 0, i32 0 store i32 %x, i32 addrspace(4)* %i ret void } -define ptx_device void @t5(i32 %x) { +define ptx_device void @t4_shared_u64(i64 %x) { +entry: +;CHECK: mov.u32 r0, array_shared_i64; +;CHECK-NEXT: st.shared.u64 [r0], rd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64] addrspace(4)* @array_shared_i64, i32 0, i32 0 + store i64 %x, i64 addrspace(4)* %i + ret void +} + +define ptx_device void @t4_shared_f32(float %x) { +entry: +;CHECK: mov.u32 r0, array_shared_float; +;CHECK-NEXT: st.shared.f32 [r0], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(4)* @array_shared_float, i32 0, i32 0 + store float %x, float addrspace(4)* %i + ret void +} + +define ptx_device void @t4_shared_f64(double %x) { +entry: +;CHECK: mov.u32 r0, array_shared_double; +;CHECK-NEXT: st.shared.f64 [r0], fd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double] addrspace(4)* @array_shared_double, i32 0, i32 0 + store double %x, double addrspace(4)* %i + ret void +} + +define ptx_device void @t5_u16(i16 %x) { entry: -;CHECK: st.global.s32 [array+4], r1; - %i = getelementptr [10 x i32]* @array, i32 0, i32 1 +;CHECK: mov.u32 r0, array_i16; +;CHECK-NEXT: st.global.u16 [r0+2], rh1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16]* @array_i16, i32 0, i32 1 + store i16 %x, i16* %i + ret void +} + +define ptx_device void @t5_u32(i32 %x) { +entry: +;CHECK: mov.u32 r0, array_i32; +;CHECK-NEXT: st.global.u32 [r0+4], r1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32]* @array_i32, i32 0, i32 1 store i32 %x, i32* %i ret void } + +define ptx_device void @t5_u64(i64 %x) { +entry: +;CHECK: mov.u32 r0, array_i64; +;CHECK-NEXT: st.global.u64 [r0+8], rd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64]* @array_i64, i32 0, i32 1 + store i64 %x, i64* %i + ret void +} + +define ptx_device void @t5_f32(float %x) { +entry: +;CHECK: mov.u32 r0, array_float; +;CHECK-NEXT: st.global.f32 [r0+4], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array_float, i32 0, i32 1 + store float %x, float* %i + ret void +} + +define ptx_device void @t5_f64(double %x) { +entry: +;CHECK: mov.u32 r0, array_double; +;CHECK-NEXT: st.global.f64 [r0+8], fd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double]* @array_double, i32 0, i32 1 + store double %x, double* %i + ret void +} diff --git a/test/CodeGen/PTX/sub.ll b/test/CodeGen/PTX/sub.ll index aab3fdadad13..7dd2c6f6ac79 100644 --- a/test/CodeGen/PTX/sub.ll +++ b/test/CodeGen/PTX/sub.ll @@ -1,15 +1,71 @@ -; RUN: llc < %s -march=ptx | FileCheck %s +; RUN: llc < %s -march=ptx32 | FileCheck %s -define ptx_device i32 @t1(i32 %x, i32 %y) { -;CHECK: sub.s32 r0, r1, r2; +define ptx_device i16 @t1_u16(i16 %x, i16 %y) { +; CHECK: sub.u16 rh0, rh1, rh2; +; CHECK-NEXT: ret; + %z = sub i16 %x, %y + ret i16 %z +} + +define ptx_device i32 @t1_u32(i32 %x, i32 %y) { +; CHECK: sub.u32 r0, r1, r2; +; CHECK-NEXT: ret; %z = sub i32 %x, %y -;CHECK: ret; ret i32 %z } -define ptx_device i32 @t2(i32 %x) { -;CHECK: add.s32 r0, r1, -1; +define ptx_device i64 @t1_u64(i64 %x, i64 %y) { +; CHECK: sub.u64 rd0, rd1, rd2; +; CHECK-NEXT: ret; + %z = sub i64 %x, %y + ret i64 %z +} + +define ptx_device float @t1_f32(float %x, float %y) { +; CHECK: sub.f32 f0, f1, f2 +; CHECK-NEXT: ret; + %z = fsub float %x, %y + ret float %z +} + +define ptx_device double @t1_f64(double %x, double %y) { +; CHECK: sub.f64 fd0, fd1, fd2 +; CHECK-NEXT: ret; + %z = fsub double %x, %y + ret double %z +} + +define ptx_device i16 @t2_u16(i16 %x) { +; CHECK: add.u16 rh0, rh1, -1; +; CHECK-NEXT: ret; + %z = sub i16 %x, 1 + ret i16 %z +} + +define ptx_device i32 @t2_u32(i32 %x) { +; CHECK: add.u32 r0, r1, -1; +; CHECK-NEXT: ret; %z = sub i32 %x, 1 -;CHECK: ret; ret i32 %z } + +define ptx_device i64 @t2_u64(i64 %x) { +; CHECK: add.u64 rd0, rd1, -1; +; CHECK-NEXT: ret; + %z = sub i64 %x, 1 + ret i64 %z +} + +define ptx_device float @t2_f32(float %x) { +; CHECK: add.f32 f0, f1, 0FBF800000; +; CHECK-NEXT: ret; + %z = fsub float %x, 1.0 + ret float %z +} + +define ptx_device double @t2_f64(double %x) { +; CHECK: add.f64 fd0, fd1, 0DBFF0000000000000; +; CHECK-NEXT: ret; + %z = fsub double %x, 1.0 + ret double %z +} |