[Mlir-commits] [mlir] [MLIR][Math] Add erfc to math dialect (PR #126439)

Jan Leyonberg llvmlistbot at llvm.org
Fri Feb 14 06:19:31 PST 2025


================
@@ -318,6 +318,24 @@ OpFoldResult math::ErfOp::fold(FoldAdaptor adaptor) {
       });
 }
 
+//===----------------------------------------------------------------------===//
+// ErfcOp folder
+//===----------------------------------------------------------------------===//
+
+OpFoldResult math::ErfcOp::fold(FoldAdaptor adaptor) {
+  return constFoldUnaryOpConditional<FloatAttr>(
+      adaptor.getOperands(), [](const APFloat &a) -> std::optional<APFloat> {
+        switch (a.getSizeInBits(a.getSemantics())) {
+        case 64:
+          return APFloat(erfc(a.convertToDouble()));
+        case 32:
----------------
jsjodin wrote:

I see your point, it would have been better to have a function that would return an enum perhaps, but this would be better  in a separate PR, since this is the pattern that is used.

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


More information about the Mlir-commits mailing list