forked from OSchip/llvm-project
MLIR: add SinOp Lowering to __nv_sinf and __nv_sin
Added lowering rule from `SinOp` to `__nv_sinf` and `__nv_sin` Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D90147
This commit is contained in:
parent
23c8da25ef
commit
1ec893c574
|
@ -138,7 +138,7 @@ struct LowerGpuOpsToNVVMOpsPass
|
|||
target.addIllegalDialect<gpu::GPUDialect>();
|
||||
target.addIllegalOp<LLVM::CosOp, LLVM::ExpOp, LLVM::FAbsOp, LLVM::FCeilOp,
|
||||
LLVM::FFloorOp, LLVM::LogOp, LLVM::Log10Op,
|
||||
LLVM::Log2Op>();
|
||||
LLVM::Log2Op, LLVM::SinOp>();
|
||||
target.addIllegalOp<FuncOp>();
|
||||
target.addLegalDialect<NVVM::NVVMDialect>();
|
||||
// TODO: Remove once we support replacing non-root ops.
|
||||
|
@ -183,6 +183,8 @@ void mlir::populateGpuToNVVMConversionPatterns(
|
|||
"__nv_log10");
|
||||
patterns.insert<OpToFuncCallLowering<Log2Op>>(converter, "__nv_log2f",
|
||||
"__nv_log2");
|
||||
patterns.insert<OpToFuncCallLowering<SinOp>>(converter, "__nv_sinf",
|
||||
"__nv_sin");
|
||||
patterns.insert<OpToFuncCallLowering<TanhOp>>(converter, "__nv_tanhf",
|
||||
"__nv_tanh");
|
||||
}
|
||||
|
|
|
@ -261,6 +261,21 @@ gpu.module @test_module {
|
|||
|
||||
// -----
|
||||
|
||||
gpu.module @test_module {
|
||||
// CHECK: llvm.func @__nv_sinf(!llvm.float) -> !llvm.float
|
||||
// CHECK: llvm.func @__nv_sin(!llvm.double) -> !llvm.double
|
||||
// CHECK-LABEL: func @gpu_sin
|
||||
func @gpu_sin(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
|
||||
%result32 = std.sin %arg_f32 : f32
|
||||
// CHECK: llvm.call @__nv_sinf(%{{.*}}) : (!llvm.float) -> !llvm.float
|
||||
%result64 = std.sin %arg_f64 : f64
|
||||
// CHECK: llvm.call @__nv_sin(%{{.*}}) : (!llvm.double) -> !llvm.double
|
||||
std.return %result32, %result64 : f32, f64
|
||||
}
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
gpu.module @test_module {
|
||||
// CHECK: llvm.func @__nv_tanhf(!llvm.float) -> !llvm.float
|
||||
// CHECK: llvm.func @__nv_tanh(!llvm.double) -> !llvm.double
|
||||
|
|
Loading…
Reference in New Issue