At present math.tan fails to lower for NVVM and ROCDL.
Differential Revision: https://reviews.llvm.org/D141505
"__nv_sqrt");
populateOpPatterns<math::TanhOp>(converter, patterns, "__nv_tanhf",
"__nv_tanh");
+ populateOpPatterns<math::TanOp>(converter, patterns, "__nv_tanf", "__nv_tan");
}
std::unique_ptr<OperationPass<gpu::GPUModuleOp>>
"__ocml_sqrt_f64");
populateOpPatterns<math::TanhOp>(converter, patterns, "__ocml_tanh_f32",
"__ocml_tanh_f64");
+ populateOpPatterns<math::TanOp>(converter, patterns, "__ocml_tan_f32",
+ "__ocml_tan_f64");
}
std::unique_ptr<OperationPass<gpu::GPUModuleOp>>
// -----
gpu.module @test_module {
+ // CHECK: llvm.func @__nv_tanf(f32) -> f32
+ // CHECK: llvm.func @__nv_tan(f64) -> f64
+ // CHECK-LABEL: func @gpu_tan
+ func.func @gpu_tan(%arg_f16 : f16, %arg_f32 : f32, %arg_f64 : f64) -> (f16, f32, f64) {
+ %result16 = math.tan %arg_f16 : f16
+ // CHECK: llvm.fpext %{{.*}} : f16 to f32
+ // CHECK-NEXT: llvm.call @__nv_tanf(%{{.*}}) : (f32) -> f32
+ // CHECK-NEXT: llvm.fptrunc %{{.*}} : f32 to f16
+ %result32 = math.tan %arg_f32 : f32
+ // CHECK: llvm.call @__nv_tanf(%{{.*}}) : (f32) -> f32
+ %result64 = math.tan %arg_f64 : f64
+ // CHECK: llvm.call @__nv_tan(%{{.*}}) : (f64) -> f64
+ func.return %result16, %result32, %result64 : f16, f32, f64
+ }
+}
+
+// -----
+
+gpu.module @test_module {
// CHECK: llvm.func @__nv_tanhf(f32) -> f32
// CHECK: llvm.func @__nv_tanh(f64) -> f64
// CHECK-LABEL: func @gpu_tanh
// -----
gpu.module @test_module {
+ // CHECK: llvm.func @__ocml_tan_f32(f32) -> f32
+ // CHECK: llvm.func @__ocml_tan_f64(f64) -> f64
+ // CHECK-LABEL: func @gpu_tan
+ func.func @gpu_tan(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
+ %result32 = math.tan %arg_f32 : f32
+ // CHECK: llvm.call @__ocml_tan_f32(%{{.*}}) : (f32) -> f32
+ %result64 = math.tan %arg_f64 : f64
+ // CHECK: llvm.call @__ocml_tan_f64(%{{.*}}) : (f64) -> f64
+ func.return %result32, %result64 : f32, f64
+ }
+}
+
+// -----
+
+gpu.module @test_module {
// CHECK: llvm.func @__ocml_tanh_f32(f32) -> f32
// CHECK: llvm.func @__ocml_tanh_f64(f64) -> f64
// CHECK-LABEL: func @gpu_tanh