Skip to content

Commit b3e05d5

Browse files
authored
[mlir][nvvm] Add conversion for math.erfc (#129329)
Add missing pattern to convert `math.erfc` operation to `__nv_erfcf` or `__nv_erfc` function call.
1 parent 21a0500 commit b3e05d5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,8 @@ void mlir::populateLibDeviceConversionPatterns(
540540
"__nv_cosh");
541541
populateOpPatterns<math::ErfOp>(converter, patterns, benefit, "__nv_erff",
542542
"__nv_erf");
543+
populateOpPatterns<math::ErfcOp>(converter, patterns, benefit, "__nv_erfcf",
544+
"__nv_erfc");
543545
populateOpPatterns<math::ExpOp>(converter, patterns, benefit, "__nv_expf",
544546
"__nv_exp", "__nv_fast_expf");
545547
populateOpPatterns<math::Exp2Op>(converter, patterns, benefit, "__nv_exp2f",

mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,3 +1095,16 @@ gpu.module @test_module_54 {
10951095
return %0, %1, %2, %3, %4, %5 : i1, i1, i1, i1, i1, i1
10961096
}
10971097
}
1098+
1099+
gpu.module @test_module_55 {
1100+
// CHECK: llvm.func @__nv_erfcf(f32) -> f32
1101+
// CHECK: llvm.func @__nv_erfc(f64) -> f64
1102+
// CHECK-LABEL: func @gpu_erf
1103+
func.func @gpu_erfc(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
1104+
%result32 = math.erfc %arg_f32 : f32
1105+
// CHECK: llvm.call @__nv_erfcf(%{{.*}}) : (f32) -> f32
1106+
%result64 = math.erfc %arg_f64 : f64
1107+
// CHECK: llvm.call @__nv_erfc(%{{.*}}) : (f64) -> f64
1108+
func.return %result32, %result64 : f32, f64
1109+
}
1110+
}

0 commit comments

Comments
 (0)