[Mlir-commits] [mlir] [mlir][arith] Expand ops for F8E4M3FN and F8E5M2 type. (PR #216653)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Aug 17 00:58:18 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- mlir/include/mlir/Dialect/Arith/Transforms/Passes.h mlir/lib/Dialect/Arith/Transforms/ExpandOps.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/Dialect/Arith/Transforms/ExpandOps.cpp b/mlir/lib/Dialect/Arith/Transforms/ExpandOps.cpp
index a7b4c8125..3234feb24 100644
--- a/mlir/lib/Dialect/Arith/Transforms/ExpandOps.cpp
+++ b/mlir/lib/Dialect/Arith/Transforms/ExpandOps.cpp
@@ -738,15 +738,14 @@ struct F8E5M2TruncFOpConverter : public OpRewritePattern<arith::TruncFOp> {
       h16 = arith::TruncFOp::create(b, f16Ty, operand, nullptr,
                                     op.getFastmathAttr());
 
-    Value isNan =
-        arith::CmpFOp::create(b, arith::CmpFPredicate::UNE, h16, h16);
+    Value isNan = arith::CmpFOp::create(b, arith::CmpFPredicate::UNE, h16, h16);
     Value h16Bits = arith::BitcastOp::create(b, i16Ty, h16);
     // Rounding bias constants for dropping the low 8 mantissa bits.
     Value c7F = createConst(op.getLoc(), i16Ty, 0x7f, rewriter);
     Value c8 = createConst(op.getLoc(), i16Ty, 8, rewriter);
     Value c1 = createConst(op.getLoc(), i16Ty, 1, rewriter);
-    Value bit8 = arith::AndIOp::create(
-        b, arith::ShRUIOp::create(b, h16Bits, c8), c1);
+    Value bit8 =
+        arith::AndIOp::create(b, arith::ShRUIOp::create(b, h16Bits, c8), c1);
     Value roundingBias = arith::AddIOp::create(b, bit8, c7F);
     Value biased = arith::AddIOp::create(b, h16Bits, roundingBias);
     Value biasedAndShifted = arith::ShRUIOp::create(b, biased, c8);
@@ -879,7 +878,8 @@ struct F8E4M3FNTruncFOpConverter : public OpRewritePattern<arith::TruncFOp> {
     Value absBits = arith::AndIOp::create(b, f32Bits, cAbsMask);
     Value absF32 = arith::BitcastOp::create(b, f32Ty, absBits);
     // Clamp to the F8E4M3FN maximum magnitude (448) then scale by 2^-8.
-    Value cMax = createFloatConst(op.getLoc(), f32Ty, APFloat(448.0f), rewriter);
+    Value cMax =
+        createFloatConst(op.getLoc(), f32Ty, APFloat(448.0f), rewriter);
     absF32 = arith::MinNumFOp::create(b, absF32, cMax);
     Value cInv256 =
         createFloatConst(op.getLoc(), f32Ty, APFloat(0.00390625f), rewriter);
@@ -906,8 +906,8 @@ struct F8E4M3FNTruncFOpConverter : public OpRewritePattern<arith::TruncFOp> {
     mag8 = arith::SelectOp::create(b, isOverflow, c7E8, mag8);
     // Re-apply the sign.
     Value c24 = createConst(op.getLoc(), i32Ty, 24, rewriter);
-    Value sign8 =
-        arith::TruncIOp::create(b, i8Ty, arith::ShRUIOp::create(b, signBits, c24));
+    Value sign8 = arith::TruncIOp::create(
+        b, i8Ty, arith::ShRUIOp::create(b, signBits, c24));
     Value res8 = arith::OrIOp::create(b, mag8, sign8);
     Value cNan8 = createConst(op.getLoc(), i8Ty, 0x7f, rewriter);
     Value res = arith::SelectOp::create(b, isNan, cNan8, res8);

``````````

</details>


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


More information about the Mlir-commits mailing list