diff --git a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp --- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp +++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp @@ -84,7 +84,7 @@ target.addIllegalDialect(); target.addIllegalOp(); + LLVM::PowOp, LLVM::SinOp, LLVM::SqrtOp>(); // TODO: Remove once we support replacing non-root ops. target.addLegalOp(); @@ -123,6 +123,8 @@ "__ocml_log10_f64"); patterns.insert>(converter, "__ocml_log2_f32", "__ocml_log2_f64"); + patterns.insert>(converter, "__ocml_pow_f32", + "__ocml_pow_f64"); patterns.insert>(converter, "__ocml_rsqrt_f32", "__ocml_rsqrt_f64"); patterns.insert>(converter, "__ocml_sin_f32", diff --git a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir --- a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir +++ b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir @@ -310,3 +310,18 @@ std.return %result32, %result64 : f32, f64 } } + +// ----- + +gpu.module @test_module { + // CHECK: llvm.func @__ocml_pow_f32(!llvm.float, !llvm.float) -> !llvm.float + // CHECK: llvm.func @__ocml_pow_f64(!llvm.double, !llvm.double) -> !llvm.double + // CHECK-LABEL: func @gpu_pow + func @gpu_pow(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) { + %result32 = std.powf %arg_f32, %arg_f32 : f32 + // CHECK: llvm.call @__ocml_pow_f32(%{{.*}}, %{{.*}}) : (!llvm.float, !llvm.float) -> !llvm.float + %result64 = std.powf %arg_f64, %arg_f64 : f64 + // CHECK: llvm.call @__ocml_pow_f64(%{{.*}}, %{{.*}}) : (!llvm.double, !llvm.double) -> !llvm.double + std.return %result32, %result64 : f32, f64 + } +}