[Mlir-commits] [mlir] [mlir][spirv] Add basic arithmetic folds (PR #71414)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Nov 6 10:23:47 PST 2023


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 521ac12a251e7cf88d3b304186081de31a7503be ce0575755c388662067c3be469a0208fb8eeb63c -- mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
``````````

</details>

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

``````````diff
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
index 16b90b80c56e..9f2d4f6715bd 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
@@ -276,16 +276,12 @@ OpFoldResult spirv::IAddCarryOp::fold(FoldAdaptor adaptor) {
   //  the component width, and 0 otherwise.
   auto operands = adaptor.getOperands();
   auto adds = constFoldBinaryOp<IntegerAttr>(
-        operands,
-        [](const APInt &a, const APInt &b) {
-          return a + b;
-        });
+      operands, [](const APInt &a, const APInt &b) { return a + b; });
   auto carrys = constFoldBinaryOp<IntegerAttr>(
-        ArrayRef{operands[0], adds},
-        [](const APInt &a, const APInt &b) {
-          APInt zero = APInt::getZero(a.getBitWidth());
-          return a.ult(b) ? zero : (zero + 1);
-        });
+      ArrayRef{operands[0], adds}, [](const APInt &a, const APInt &b) {
+        APInt zero = APInt::getZero(a.getBitWidth());
+        return a.ult(b) ? zero : (zero + 1);
+      });
   // FIXME: How can we return this as a the spirv.constant attr? Maybe
   // DenseElementAttr or ArrayAttr? Neither seem to do the trick :(
   return ArrayAttr::get(getContext(), {carrys, adds});

``````````

</details>


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


More information about the Mlir-commits mailing list