[llvm] [mlir] [MLIR][ROCDL] Add dynamically legal ops to LowerGpuOpsToROCDLOpsPass (PR #108302)

Nirvedh Meshram via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 08:45:21 PDT 2024


================
@@ -332,7 +334,13 @@ void mlir::configureGpuToROCDLConversionLegality(ConversionTarget &target) {
   target.addIllegalOp<LLVM::CosOp, LLVM::ExpOp, LLVM::Exp2Op, LLVM::FCeilOp,
                       LLVM::FFloorOp, LLVM::FRemOp, LLVM::LogOp, LLVM::Log10Op,
                       LLVM::Log2Op, LLVM::PowOp, LLVM::SinOp>();
-
+  // These ops are not legal for f64 type but are legal for narrower float
+  // types.
+  target.addDynamicallyLegalOp<LLVM::ExpOp, LLVM::LogOp>([](Operation *op) {
+    return any_of(op->getOperandTypes(), [](Type type) {
+      return isa<FloatType>(type) && type.getIntOrFloatBitWidth() < 64;
----------------
nirvedhmeshram wrote:

I know it for sure it handles f16 and f32 but dont know about other types, like bf16 and f8, I am okay being more prescriptive here and only allowing these two types for now. The other types will create a crash in the LLVM IR conversion but we can decide how we want to support them once we see those cases.

https://github.com/llvm/llvm-project/pull/108302


More information about the llvm-commits mailing list