|
| 1 | +; RUN: llc < %s -march=nvptx64 | FileCheck %s --check-prefixes CHECK,CHECK-APPROX-OPT,CHECK-SQRT-NOOPT |
| 2 | +; RUN: llc < %s -march=nvptx64 -nvptx-prec-sqrtf32=0 | FileCheck %s --check-prefixes CHECK,CHECK-APPROX-OPT,CHECK-SQRT-OPT |
| 3 | +; RUN: llc < %s -march=nvptx64 -nvptx-rsqrt-approx-opt=0 | FileCheck %s --check-prefixes CHECK,CHECK-APPROX-NOOPT,CHECK-SQRT-NOOPT |
| 4 | +; |
| 5 | +; RUN: %if ptxas %{ llc < %s -march=nvptx64 | %ptxas-verify %} |
| 6 | +; RUN: %if ptxas %{ llc < %s -march=nvptx64 -nvptx-prec-sqrtf32=0 | %ptxas-verify %} |
| 7 | +; RUN: %if ptxas %{ llc < %s -march=nvptx64 -nvptx-rsqrt-approx-opt=0 | %ptxas-verify %} |
| 8 | + |
| 9 | + |
| 10 | +; CHECK-LABEL: .func{{.*}}test1 |
| 11 | +define float @test1(float %in) local_unnamed_addr { |
| 12 | +; CHECK-APPROX-OPT: rsqrt.approx.f32 |
| 13 | +; CHECK-APPROX-NOOPT: sqrt.approx.f32 |
| 14 | +; CHECK-APPROX-NOOPT-NEXT: rcp.rn.f32 |
| 15 | + %sqrt = tail call float @llvm.nvvm.sqrt.approx.f(float %in) |
| 16 | + %rsqrt = fdiv float 1.0, %sqrt |
| 17 | + ret float %rsqrt |
| 18 | +} |
| 19 | +; CHECK-LABEL: .func{{.*}}test2 |
| 20 | +define float @test2(float %in) local_unnamed_addr { |
| 21 | +; CHECK-APPROX-OPT: rsqrt.approx.ftz.f32 |
| 22 | +; CHECK-APPROX-NOOPT: sqrt.approx.ftz.f32 |
| 23 | +; CHECK-APPROX-NOOPT-NEXT: rcp.rn.f32 |
| 24 | + %sqrt = tail call float @llvm.nvvm.sqrt.approx.ftz.f(float %in) |
| 25 | + %rsqrt = fdiv float 1.0, %sqrt |
| 26 | + ret float %rsqrt |
| 27 | +} |
| 28 | + |
| 29 | +; CHECK-LABEL: .func{{.*}}test3 |
| 30 | +define float @test3(float %in) local_unnamed_addr { |
| 31 | +; CHECK-SQRT-OPT: rsqrt.approx.f32 |
| 32 | +; CHECK-SQRT-NOOPT: sqrt.rn.f32 |
| 33 | +; CHECK-SQRT-NOOPT-NEXT: rcp.rn.f32 |
| 34 | + %sqrt = tail call float @llvm.nvvm.sqrt.f(float %in) |
| 35 | + %rsqrt = fdiv float 1.0, %sqrt |
| 36 | + ret float %rsqrt |
| 37 | +} |
| 38 | + |
| 39 | +; CHECK-LABEL: .func{{.*}}test4 |
| 40 | +define float @test4(float %in) local_unnamed_addr #0 { |
| 41 | +; CHECK-SQRT-OPT: rsqrt.approx.ftz.f32 |
| 42 | +; CHECK-SQRT-NOOPT: sqrt.rn.ftz.f32 |
| 43 | +; CHECK-SQRT-NOOPT-NEXT: rcp.rn.ftz.f32 |
| 44 | + %sqrt = tail call float @llvm.nvvm.sqrt.f(float %in) |
| 45 | + %rsqrt = fdiv float 1.0, %sqrt |
| 46 | + ret float %rsqrt |
| 47 | +} |
| 48 | + |
| 49 | +; CHECK-LABEL: .func{{.*}}test5 |
| 50 | +define float @test5(float %in) local_unnamed_addr { |
| 51 | +; CHECK-SQRT-OPT: rsqrt.approx.f32 |
| 52 | +; CHECK-SQRT-NOOPT: sqrt.rn.f32 |
| 53 | +; CHECK-SQRT-NOOPT-NEXT: rcp.rn.f32 |
| 54 | + %sqrt = tail call float @llvm.sqrt.f32(float %in) |
| 55 | + %rsqrt = fdiv float 1.0, %sqrt |
| 56 | + ret float %rsqrt |
| 57 | +} |
| 58 | + |
| 59 | +; CHECK-LABEL: .func{{.*}}test6 |
| 60 | +define float @test6(float %in) local_unnamed_addr #0 { |
| 61 | +; CHECK-SQRT-OPT: rsqrt.approx.ftz.f32 |
| 62 | +; CHECK-SQRT-NOOPT: sqrt.rn.ftz.f32 |
| 63 | +; CHECK-SQRT-NOOPT-NEXT: rcp.rn.ftz.f32 |
| 64 | + %sqrt = tail call float @llvm.sqrt.f32(float %in) |
| 65 | + %rsqrt = fdiv float 1.0, %sqrt |
| 66 | + ret float %rsqrt |
| 67 | +} |
| 68 | + |
| 69 | + |
| 70 | +declare float @llvm.nvvm.sqrt.f(float) |
| 71 | +declare float @llvm.nvvm.sqrt.approx.f(float) |
| 72 | +declare float @llvm.nvvm.sqrt.approx.ftz.f(float) |
| 73 | +declare float @llvm.sqrt.f32(float) |
| 74 | + |
| 75 | +attributes #0 = { "denormal-fp-math-f32" = "preserve-sign" } |
0 commit comments