[Mlir-commits] [mlir] [mlir][math]Update `convertPowfOp` `ExpandPatterns.cpp` (PR #124402)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Jan 25 03:11:30 PST 2025


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 2696e4fb9567d23ce065a067e7f4909b310daf50 5e65430b11da9d739b8b0bd82a0d51bdaaefc6cd --extensions cpp -- mlir/lib/Dialect/Math/Transforms/ExpandPatterns.cpp
``````````

</details>

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

``````````diff
diff --git a/mlir/lib/Dialect/Math/Transforms/ExpandPatterns.cpp b/mlir/lib/Dialect/Math/Transforms/ExpandPatterns.cpp
index 314b5b3020..9000a4de98 100644
--- a/mlir/lib/Dialect/Math/Transforms/ExpandPatterns.cpp
+++ b/mlir/lib/Dialect/Math/Transforms/ExpandPatterns.cpp
@@ -328,8 +328,10 @@ static LogicalResult convertPowfOp(math::PowFOp op, PatternRewriter &rewriter) {
   Value absA = b.create<math::AbsFOp>(opType, operandA);
 
   // Compute sign(a) as -1.0 if a < 0, else 1.0
-  Value isNegative = b.create<arith::CmpFOp>(arith::CmpFPredicate::OLT, operandA, zero);
-  Value signA = b.create<arith::SelectOp>(op->getLoc(), isNegative, negOne, one);
+  Value isNegative =
+      b.create<arith::CmpFOp>(arith::CmpFPredicate::OLT, operandA, zero);
+  Value signA =
+      b.create<arith::SelectOp>(op->getLoc(), isNegative, negOne, one);
 
   // Compute ln(|a|)
   Value logA = b.create<math::LogOp>(opType, absA);
@@ -349,10 +351,10 @@ static LogicalResult convertPowfOp(math::PowFOp op, PatternRewriter &rewriter) {
   // powers of negatives. Then, we ensure that one is produced if `b` is zero.
   // This corresponds to `libm` behavior, even for `0^0`. Without this check,
   // `exp(0 * ln(0)) = exp(0 *-inf) = exp(-nan) = -nan`.
-  Value zeroCheck = 
-    b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, operandB, zero);
-  Value finalResult = 
-    b.create<arith::SelectOp>(op->getLoc(), zeroCheck, one, resultWithSign);
+  Value zeroCheck =
+      b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, operandB, zero);
+  Value finalResult =
+      b.create<arith::SelectOp>(op->getLoc(), zeroCheck, one, resultWithSign);
   rewriter.replaceOp(op, finalResult);
   return success();
 }

``````````

</details>


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


More information about the Mlir-commits mailing list