[Mlir-commits] [mlir] [mlir][arith] Add LUT-based lowering of arith.extf for FP8 to F32. (PR #196321)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu May 7 07:12:22 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/Conversion/ArithToLUT/ArithToLUT.h mlir/lib/Conversion/ArithToLUT/ArithToLUT.cpp mlir/unittests/Conversion/ArithToLUT/ArithToLUTTest.cpp mlir/include/mlir/Conversion/Passes.h --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/Conversion/ArithToLUT/ArithToLUT.cpp b/mlir/lib/Conversion/ArithToLUT/ArithToLUT.cpp
index ad03c7014..bc4ddb92d 100644
--- a/mlir/lib/Conversion/ArithToLUT/ArithToLUT.cpp
+++ b/mlir/lib/Conversion/ArithToLUT/ArithToLUT.cpp
@@ -149,9 +149,8 @@ struct ExtFToLUTPattern : public OpRewritePattern<arith::ExtFOp> {
Value tbl = memref::GetGlobalOp::create(rewriter, loc, memrefTy,
global.getSymName());
// %i8 = arith.bitcast %in : f8X -> i8
- Value i8val = arith::BitcastOp::create(rewriter, loc,
- rewriter.getIntegerType(8),
- op.getIn());
+ Value i8val = arith::BitcastOp::create(
+ rewriter, loc, rewriter.getIntegerType(8), op.getIn());
// %ui32 = arith.extui %i8 : i8 -> i32
Value ui32val =
diff --git a/mlir/unittests/Conversion/ArithToLUT/ArithToLUTTest.cpp b/mlir/unittests/Conversion/ArithToLUT/ArithToLUTTest.cpp
index 884cc5dc2..79474e723 100644
--- a/mlir/unittests/Conversion/ArithToLUT/ArithToLUTTest.cpp
+++ b/mlir/unittests/Conversion/ArithToLUT/ArithToLUTTest.cpp
@@ -68,7 +68,8 @@ static LogicalResult lowerToLLVM(ModuleOp module) {
}
// Builds a module with function:
-// func @test(%arg0: i32) -> f32 { trunci i32 to i8; bitcast i8 to f8; extf f8 to f32 }
+// func @test(%arg0: i32) -> f32 { trunci i32 to i8; bitcast i8 to f8; extf f8
+// to f32 }
static std::string makeModule(const char *f8TypeName) {
std::string s;
s += "func.func @test(%arg0: i32) -> f32 "
@@ -113,21 +114,20 @@ static void runExhaustiveTest(const F8Format &fmt) {
llvm::APFloat ref(sem, llvm::APInt(8, static_cast<uint64_t>(i)));
bool lossy = false;
- ref.convert(llvm::APFloat::IEEEsingle(),
- llvm::APFloat::rmNearestTiesToEven, &lossy);
+ ref.convert(llvm::APFloat::IEEEsingle(), llvm::APFloat::rmNearestTiesToEven,
+ &lossy);
float expected = ref.convertToFloat();
if (std::isnan(expected)) {
EXPECT_TRUE(std::isnan(got))
- << fmt.mlirName << " pattern " << i
- << ": expected NaN, got " << got;
+ << fmt.mlirName << " pattern " << i << ": expected NaN, got " << got;
} else {
uint32_t gotBits = 0, expBits = 0;
std::memcpy(&gotBits, &got, 4);
std::memcpy(&expBits, &expected, 4);
EXPECT_EQ(gotBits, expBits)
- << fmt.mlirName << " pattern " << i
- << ": expected " << expected << ", got " << got;
+ << fmt.mlirName << " pattern " << i << ": expected " << expected
+ << ", got " << got;
}
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/196321
More information about the Mlir-commits
mailing list