[Mlir-commits] [mlir] [MLIR][Math][XeVM] Add MathToXeVM (`math-to-xevm`) pass (PR #159878)

Ian Li llvmlistbot at llvm.org
Fri Oct 10 06:56:06 PDT 2025


================
@@ -796,6 +796,32 @@ def ConvertMathToSPIRVPass : Pass<"convert-math-to-spirv"> {
   let dependentDialects = ["spirv::SPIRVDialect"];
 }
 
+//===----------------------------------------------------------------------===//
+// MathToXeVM
+//===----------------------------------------------------------------------===//
+
+def ConvertMathToXeVM : Pass<"convert-math-to-xevm", "ModuleOp"> {
+  let summary =
+      "Convert (fast) math operations to native XeVM/SPIRV equivalents";
+  let description = [{
+    This pass converts supported math ops marked with the `afn` fastmath flag
+    to function calls for OpenCL `native_` math intrinsics: These intrinsics
+    are typically mapped directly to native device instructions, often resulting
+    in better performance. However, the precision/error of these intrinsics
+    are implementation-defined, and thus math ops are only converted when they
+    have the `afn` fastmath flag enabled.
+  }];
+  let options = [Option<
+      "convertArith", "convert-arith", "bool", /*default=*/"true",
----------------
ianayl wrote:

The `convertArith` option would convert e.g. `arith.divide`: a user may have specific optimizations that apply to basic operations like division later on, rather than relying on a native version of it; I had a conversation with Abdullah (mshahneo) and decided having an option to disable converting more elementary operations would be a nice to have.

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


More information about the Mlir-commits mailing list