[PATCH] D74389: [MLIR][GPU] Disallow llvm tanh intrinsics when lowering to NVVM/ROCm.
Stephan Herhut via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 11 06:19:34 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG890d5e2dd232: [MLIR][GPU] Disallow llvm tanh intrinsics when lowering to NVVM/ROCm. (authored by herhut).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74389/new/
https://reviews.llvm.org/D74389
Files:
mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
Index: mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
===================================================================
--- mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
+++ mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
@@ -65,8 +65,9 @@
target.addLegalDialect<LLVM::LLVMDialect, ROCDL::ROCDLDialect>();
target.addIllegalOp<LLVM::FAbsOp, LLVM::FCeilOp, LLVM::CosOp,
LLVM::ExpOp>();
- target.addDynamicallyLegalOp<FuncOp>(
- [&](FuncOp op) { return converter.isSignatureLegal(op.getType()); });
+ target.addDynamicallyLegalOp<LLVM::CallOp>(
+ gpu::filterIllegalLLVMIntrinsics({"tanh", "tanhf"}, m.getContext()));
+ target.addIllegalOp<FuncOp>();
if (failed(applyPartialConversion(m, target, patterns, &converter)))
signalPassFailure();
}
Index: mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
===================================================================
--- mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -695,6 +695,8 @@
target.addIllegalOp<FuncOp>();
target.addLegalDialect<LLVM::LLVMDialect>();
target.addLegalDialect<NVVM::NVVMDialect>();
+ target.addDynamicallyLegalOp<mlir::LLVM::CallOp>(
+ gpu::filterIllegalLLVMIntrinsics({"tanh", "tanhf"}, m.getContext()));
// TODO(csigg): Remove once we support replacing non-root ops.
target.addLegalOp<gpu::YieldOp, gpu::GPUModuleOp, gpu::ModuleEndOp>();
if (failed(applyPartialConversion(m, target, patterns, &converter)))
Index: mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
===================================================================
--- mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
+++ mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
@@ -95,6 +95,24 @@
const std::string f64Func;
};
+namespace gpu {
+/// Returns a predicate to be used with addDynamicallyLegalOp. The predicate
+/// returns false for calls to the provided intrinsics and true otherwise.
+inline std::function<bool(Operation *)>
+filterIllegalLLVMIntrinsics(ArrayRef<StringRef> intrinsics, MLIRContext *ctx) {
+ SmallVector<StringRef, 4> illegalIds(intrinsics.begin(), intrinsics.end());
+ return [illegalIds](Operation *op) -> bool {
+ LLVM::CallOp callOp = dyn_cast<LLVM::CallOp>(op);
+ if (!callOp || !callOp.callee())
+ return true;
+ StringRef callee = callOp.callee().getValue();
+ return !llvm::any_of(illegalIds, [callee](StringRef intrinsic) {
+ return callee.equals(intrinsic);
+ });
+ };
+}
+} // namespace gpu
+
} // namespace mlir
#endif // MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74389.243846.patch
Type: text/x-patch
Size: 2716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200211/ccd207c5/attachment.bin>
More information about the llvm-commits
mailing list