Add log1p lowering from standard to NVVM intrinsics
authorFrederik Gossen <frgossen@google.com>
Thu, 21 Jan 2021 12:56:25 +0000 (13:56 +0100)
committerFrederik Gossen <frgossen@google.com>
Thu, 21 Jan 2021 13:00:38 +0000 (14:00 +0100)
Differential Revision: https://reviews.llvm.org/D95130

mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir

index a968f92..f99b7ca 100644 (file)
@@ -187,6 +187,8 @@ void mlir::populateGpuToNVVMConversionPatterns(
                                                   "__nv_floor");
   patterns.insert<OpToFuncCallLowering<LogOp>>(converter, "__nv_logf",
                                                "__nv_log");
+  patterns.insert<OpToFuncCallLowering<Log1pOp>>(converter, "__nv_log1pf",
+                                                 "__nv_log1p");
   patterns.insert<OpToFuncCallLowering<Log10Op>>(converter, "__nv_log10f",
                                                  "__nv_log10");
   patterns.insert<OpToFuncCallLowering<Log2Op>>(converter, "__nv_log2f",
index e740aab..f48ee0e 100644 (file)
@@ -247,6 +247,21 @@ gpu.module @test_module {
 // -----
 
 gpu.module @test_module {
+  // CHECK: llvm.func @__nv_log1pf(f32) -> f32
+  // CHECK: llvm.func @__nv_log1p(f64) -> f64
+  // CHECK-LABEL: func @gpu_log1p
+  func @gpu_log1p(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
+    %result32 = std.log1p %arg_f32 : f32
+    // CHECK: llvm.call @__nv_log1pf(%{{.*}}) : (f32) -> f32
+    %result64 = std.log1p %arg_f64 : f64
+    // CHECK: llvm.call @__nv_log1p(%{{.*}}) : (f64) -> f64
+    std.return %result32, %result64 : f32, f64
+  }
+}
+
+// -----
+
+gpu.module @test_module {
   // CHECK: llvm.func @__nv_log2f(f32) -> f32
   // CHECK: llvm.func @__nv_log2(f64) -> f64
   // CHECK-LABEL: func @gpu_log2