[Mlir-commits] [mlir] [mlir][SPIR-V] Fix math.powf lowering for non-integer exponents (PR #197727)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri May 15 07:12:14 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 -- mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.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/Conversion/MathToSPIRV/MathToSPIRV.cpp b/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp
index 4667b6920..58d147677 100644
--- a/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp
+++ b/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp
@@ -379,30 +379,29 @@ struct PowFOpPattern final : public OpConversionPattern<math::PowFOp> {
SmallVector<bool> oddMask;
bool isIntegerValued = false;
if (matchPattern(adaptor.getRhs(), m_Constant(&rhsAttr))) {
- isIntegerValued =
- TypeSwitch<Attribute, bool>(rhsAttr)
- .Case([&](FloatAttr a) {
- if (!a.getValue().isInteger())
- return false;
- oddMask.push_back(isOdd(a.getValue()));
- return true;
- })
- .Case([&](SplatElementsAttr a) {
- APFloat v = a.getSplatValue<APFloat>();
- if (!v.isInteger())
- return false;
- oddMask.push_back(isOdd(v));
- return true;
- })
- .Case([&](DenseElementsAttr a) {
- for (const APFloat &v : a.getValues<APFloat>()) {
- if (!v.isInteger())
- return false;
- oddMask.push_back(isOdd(v));
- }
- return true;
- })
- .Default(false);
+ isIntegerValued = TypeSwitch<Attribute, bool>(rhsAttr)
+ .Case([&](FloatAttr a) {
+ if (!a.getValue().isInteger())
+ return false;
+ oddMask.push_back(isOdd(a.getValue()));
+ return true;
+ })
+ .Case([&](SplatElementsAttr a) {
+ APFloat v = a.getSplatValue<APFloat>();
+ if (!v.isInteger())
+ return false;
+ oddMask.push_back(isOdd(v));
+ return true;
+ })
+ .Case([&](DenseElementsAttr a) {
+ for (const APFloat &v : a.getValues<APFloat>()) {
+ if (!v.isInteger())
+ return false;
+ oddMask.push_back(isOdd(v));
+ }
+ return true;
+ })
+ .Default(false);
}
if (!isIntegerValued) {
@@ -436,8 +435,7 @@ struct PowFOpPattern final : public OpConversionPattern<math::PowFOp> {
// Mixed parity (non-splat dense vector): AND lhs<0 with a per-element
// constant odd-mask.
auto vecType = cast<VectorType>(operandType);
- auto maskType =
- VectorType::get(vecType.getShape(), rewriter.getI1Type());
+ auto maskType = VectorType::get(vecType.getShape(), rewriter.getI1Type());
Value oddConst = spirv::ConstantOp::create(
rewriter, loc, maskType, DenseElementsAttr::get(maskType, oddMask));
shouldNegate =
``````````
</details>
https://github.com/llvm/llvm-project/pull/197727
More information about the Mlir-commits
mailing list