[Mlir-commits] [mlir] 6e2e4d4 - Revert "[MLIR][Arith] Add denormal attribute to binary/unary operations (#112700)"
lorenzo chelini
llvmlistbot at llvm.org
Mon Dec 9 19:18:45 PST 2024
Author: lorenzo chelini
Date: 2024-12-10T04:18:20+01:00
New Revision: 6e2e4d446c2fa43b6cebf97d947bdc60f7f9dc0b
URL: https://github.com/llvm/llvm-project/commit/6e2e4d446c2fa43b6cebf97d947bdc60f7f9dc0b
DIFF: https://github.com/llvm/llvm-project/commit/6e2e4d446c2fa43b6cebf97d947bdc60f7f9dc0b.diff
LOG: Revert "[MLIR][Arith] Add denormal attribute to binary/unary operations (#112700)"
This reverts commit 4a7b56e6e7dd0f83c379ad06b6e81450bc691ba6.
There is no agreement.
Added:
Modified:
mlir/include/mlir/Conversion/ArithCommon/AttrToLLVMConverter.h
mlir/include/mlir/Dialect/Arith/IR/ArithBase.td
mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
mlir/include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.td
mlir/include/mlir/IR/Matchers.h
mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp
mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td
mlir/lib/Dialect/Arith/IR/ArithOps.cpp
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/test/CAPI/ir.c
mlir/test/Dialect/Arith/canonicalize.mlir
mlir/test/Dialect/Arith/ops.mlir
mlir/test/Dialect/Linalg/invalid.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Conversion/ArithCommon/AttrToLLVMConverter.h b/mlir/include/mlir/Conversion/ArithCommon/AttrToLLVMConverter.h
index da067410db5eff..7ffc8613317603 100644
--- a/mlir/include/mlir/Conversion/ArithCommon/AttrToLLVMConverter.h
+++ b/mlir/include/mlir/Conversion/ArithCommon/AttrToLLVMConverter.h
@@ -51,7 +51,7 @@ getLLVMDefaultFPExceptionBehavior(MLIRContext &context);
template <typename SourceOp, typename TargetOp>
class AttrConvertFastMathToLLVM {
public:
- explicit AttrConvertFastMathToLLVM(SourceOp srcOp) {
+ AttrConvertFastMathToLLVM(SourceOp srcOp) {
// Copy the source attributes.
convertedAttr = NamedAttrList{srcOp->getAttrs()};
// Get the name of the arith fastmath attribute.
@@ -81,7 +81,7 @@ class AttrConvertFastMathToLLVM {
template <typename SourceOp, typename TargetOp>
class AttrConvertOverflowToLLVM {
public:
- explicit AttrConvertOverflowToLLVM(SourceOp srcOp) {
+ AttrConvertOverflowToLLVM(SourceOp srcOp) {
// Copy the source attributes.
convertedAttr = NamedAttrList{srcOp->getAttrs()};
// Get the name of the arith overflow attribute.
@@ -109,7 +109,7 @@ class AttrConverterConstrainedFPToLLVM {
"LLVM::FPExceptionBehaviorOpInterface");
public:
- explicit AttrConverterConstrainedFPToLLVM(SourceOp srcOp) {
+ AttrConverterConstrainedFPToLLVM(SourceOp srcOp) {
// Copy the source attributes.
convertedAttr = NamedAttrList{srcOp->getAttrs()};
diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithBase.td b/mlir/include/mlir/Dialect/Arith/IR/ArithBase.td
index d27ea5edcc8c8d..19a2ade2e95a0e 100644
--- a/mlir/include/mlir/Dialect/Arith/IR/ArithBase.td
+++ b/mlir/include/mlir/Dialect/Arith/IR/ArithBase.td
@@ -181,37 +181,4 @@ def Arith_RoundingModeAttr : I32EnumAttr<
let cppNamespace = "::mlir::arith";
}
-//===----------------------------------------------------------------------===//
-// Arith_DenormalMode
-//===----------------------------------------------------------------------===//
-
-// Denormal mode is applied on operands and results. For example, if denormal =
-// preserve_sign, operands and results will be flushed to sign preserving zero.
-// We do not distinguish between operands and results.
-
-// The default mode. Denormals are preserved and processed as defined
-// by IEEE 754 rules.
-def Arith_DenormalModeIEEE : I32EnumAttrCase<"ieee", 0>;
-
-// A mode where denormal numbers are flushed to zero, but the sign of the zero
-// (+0 or -0) is preserved.
-def Arith_DenormalModePreserveSign : I32EnumAttrCase<"preserve_sign", 1>;
-
-// A mode where all denormal numbers are flushed to positive zero (+0),
-// ignoring the sign of the original number.
-def Arith_DenormalModePositiveZero : I32EnumAttrCase<"positive_zero", 2>;
-
-def Arith_DenormalMode : I32EnumAttr<
- "DenormalMode", "denormal mode arith",
- [Arith_DenormalModeIEEE, Arith_DenormalModePreserveSign,
- Arith_DenormalModePositiveZero]> {
- let cppNamespace = "::mlir::arith";
- let genSpecializedAttr = 0;
-}
-
-def Arith_DenormalModeAttr :
- EnumAttr<Arith_Dialect, Arith_DenormalMode, "denormal"> {
- let assemblyFormat = "`<` $value `>`";
-}
-
#endif // ARITH_BASE
diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
index af8bf36397b5b1..2f71caaa593a6c 100644
--- a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
+++ b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
@@ -61,35 +61,26 @@ class Arith_TotalIntBinaryOp<string mnemonic, list<Trait> traits = []> :
// Base class for floating point unary operations.
class Arith_FloatUnaryOp<string mnemonic, list<Trait> traits = []> :
Arith_UnaryOp<mnemonic,
- !listconcat([DeclareOpInterfaceMethods<ArithFastMathInterface>,
- DeclareOpInterfaceMethods<ArithDenormalModeInterface>],
+ !listconcat([DeclareOpInterfaceMethods<ArithFastMathInterface>],
traits)>,
Arguments<(ins FloatLike:$operand,
DefaultValuedAttr<
- Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath,
- DefaultValuedAttr<
- Arith_DenormalModeAttr, "::mlir::arith::DenormalMode::ieee">:$denormal)>,
+ Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath)>,
Results<(outs FloatLike:$result)> {
let assemblyFormat = [{ $operand (`fastmath` `` $fastmath^)?
- (`denormal` `` $denormal^)?
attr-dict `:` type($result) }];
}
// Base class for floating point binary operations.
class Arith_FloatBinaryOp<string mnemonic, list<Trait> traits = []> :
Arith_BinaryOp<mnemonic,
- !listconcat([Pure,
- DeclareOpInterfaceMethods<ArithFastMathInterface>,
- DeclareOpInterfaceMethods<ArithDenormalModeInterface>],
+ !listconcat([Pure, DeclareOpInterfaceMethods<ArithFastMathInterface>],
traits)>,
Arguments<(ins FloatLike:$lhs, FloatLike:$rhs,
DefaultValuedAttr<
- Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath,
- DefaultValuedAttr<
- Arith_DenormalModeAttr, "::mlir::arith::DenormalMode::ieee">:$denormal)>,
+ Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath)>,
Results<(outs FloatLike:$result)> {
- let assemblyFormat = [{ $lhs `,` $rhs (`fastmath` `` $fastmath^)?
- (`denormal` `` $denormal^)?
+ let assemblyFormat = [{ $lhs `,` $rhs (`fastmath` `` $fastmath^)?
attr-dict `:` type($result) }];
}
@@ -1094,6 +1085,7 @@ def Arith_MinUIOp : Arith_TotalIntBinaryOp<"minui", [Commutative]> {
let hasFolder = 1;
}
+
//===----------------------------------------------------------------------===//
// MulFOp
//===----------------------------------------------------------------------===//
@@ -1119,6 +1111,8 @@ def Arith_MulFOp : Arith_FloatBinaryOp<"mulf", [Commutative]> {
%x = arith.mulf %y, %z : tensor<4x?xbf16>
```
+ TODO: In the distant future, this will accept optional attributes for fast
+ math, contraction, rounding mode, and other controls.
}];
let hasFolder = 1;
let hasCanonicalizer = 1;
diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.td b/mlir/include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.td
index 270d80f2ec73af..82d6c9ad6b03da 100644
--- a/mlir/include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.td
+++ b/mlir/include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.td
@@ -45,12 +45,13 @@ def ArithFastMathInterface : OpInterface<"ArithFastMathInterface"> {
return "fastmath";
}]
>
+
];
}
def ArithIntegerOverflowFlagsInterface : OpInterface<"ArithIntegerOverflowFlagsInterface"> {
let description = [{
- Access to operation integer overflow flags.
+ Access to op integer overflow flags.
}];
let cppNamespace = "::mlir::arith";
@@ -107,7 +108,7 @@ def ArithIntegerOverflowFlagsInterface : OpInterface<"ArithIntegerOverflowFlagsI
def ArithRoundingModeInterface : OpInterface<"ArithRoundingModeInterface"> {
let description = [{
- Access to operation rounding mode.
+ Access to op rounding mode.
}];
let cppNamespace = "::mlir::arith";
@@ -138,39 +139,4 @@ def ArithRoundingModeInterface : OpInterface<"ArithRoundingModeInterface"> {
];
}
-
-def ArithDenormalModeInterface : OpInterface<"ArithDenormalModeInterface"> {
- let description = [{
- Access the operation denormal modes.
- }];
-
- let cppNamespace = "::mlir::arith";
-
- let methods = [
- InterfaceMethod<
- /*desc=*/ "Returns a DenormalModeAttr attribute for the operation",
- /*returnType=*/ "DenormalModeAttr",
- /*methodName=*/ "getDenormalModeAttr",
- /*args=*/ (ins),
- /*methodBody=*/ [{}],
- /*defaultImpl=*/ [{
- auto op = cast<ConcreteOp>(this->getOperation());
- return op.getDenormalAttr();
- }]
- >,
- StaticInterfaceMethod<
- /*desc=*/ [{Returns the name of the DenormalModeAttr attribute for
- the operation}],
- /*returnType=*/ "StringRef",
- /*methodName=*/ "getDenormalModeAttrName",
- /*args=*/ (ins),
- /*methodBody=*/ [{}],
- /*defaultImpl=*/ [{
- return "denormal";
- }]
- >
- ];
-}
-
-
#endif // ARITH_OPS_INTERFACES
diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h
index 816ef56e4db8ca..d218206e50f8f1 100644
--- a/mlir/include/mlir/IR/Matchers.h
+++ b/mlir/include/mlir/IR/Matchers.h
@@ -438,12 +438,6 @@ inline detail::constant_float_predicate_matcher m_NegInfFloat() {
}};
}
-/// Matches a constant scalar / vector splat / tensor splat with denormal
-/// values.
-inline detail::constant_float_predicate_matcher m_isDenormalFloat() {
- return {[](const APFloat &value) { return value.isDenormal(); }};
-}
-
/// Matches a constant scalar / vector splat / tensor splat integer zero.
inline detail::constant_int_predicate_matcher m_Zero() {
return {[](const APInt &value) { return 0 == value; }};
diff --git a/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp b/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp
index 54d941ae9f6c89..aac24f113d891f 100644
--- a/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp
+++ b/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp
@@ -53,40 +53,13 @@ struct ConstrainedVectorConvertToLLVMPattern
}
};
-template <typename SourceOp, typename TargetOp,
- template <typename, typename> typename AttrConvert =
- AttrConvertPassThrough>
-struct DenormalOpConversionToLLVMPattern
- : public VectorConvertToLLVMPattern<SourceOp, TargetOp, AttrConvert> {
- using VectorConvertToLLVMPattern<SourceOp, TargetOp,
- AttrConvert>::VectorConvertToLLVMPattern;
-
- LogicalResult
- matchAndRewrite(SourceOp op, typename SourceOp::Adaptor adaptor,
- ConversionPatternRewriter &rewriter) const override {
- // TODO: Here, we need a legalization step. LLVM provides a function-level
- // attribute for denormal; here, we need to move this information from the
- // operation to the function, making sure all the operations in the same
- // function are consistent.
- if (op.getDenormalModeAttr().getValue() != arith::DenormalMode::ieee)
- return rewriter.notifyMatchFailure(
- op, "only ieee denormal mode is supported at the moment");
-
- StringRef arithDenormalAttrName = SourceOp::getDenormalModeAttrName();
- op->removeAttr(arithDenormalAttrName);
- return VectorConvertToLLVMPattern<SourceOp, TargetOp,
- AttrConvert>::matchAndRewrite(op, adaptor,
- rewriter);
- }
-};
-
//===----------------------------------------------------------------------===//
// Straightforward Op Lowerings
//===----------------------------------------------------------------------===//
using AddFOpLowering =
- DenormalOpConversionToLLVMPattern<arith::AddFOp, LLVM::FAddOp,
- arith::AttrConvertFastMathToLLVM>;
+ VectorConvertToLLVMPattern<arith::AddFOp, LLVM::FAddOp,
+ arith::AttrConvertFastMathToLLVM>;
using AddIOpLowering =
VectorConvertToLLVMPattern<arith::AddIOp, LLVM::AddOp,
arith::AttrConvertOverflowToLLVM>;
@@ -94,8 +67,8 @@ using AndIOpLowering = VectorConvertToLLVMPattern<arith::AndIOp, LLVM::AndOp>;
using BitcastOpLowering =
VectorConvertToLLVMPattern<arith::BitcastOp, LLVM::BitcastOp>;
using DivFOpLowering =
- DenormalOpConversionToLLVMPattern<arith::DivFOp, LLVM::FDivOp,
- arith::AttrConvertFastMathToLLVM>;
+ VectorConvertToLLVMPattern<arith::DivFOp, LLVM::FDivOp,
+ arith::AttrConvertFastMathToLLVM>;
using DivSIOpLowering =
VectorConvertToLLVMPattern<arith::DivSIOp, LLVM::SDivOp>;
using DivUIOpLowering =
@@ -110,38 +83,38 @@ using FPToSIOpLowering =
using FPToUIOpLowering =
VectorConvertToLLVMPattern<arith::FPToUIOp, LLVM::FPToUIOp>;
using MaximumFOpLowering =
- DenormalOpConversionToLLVMPattern<arith::MaximumFOp, LLVM::MaximumOp,
- arith::AttrConvertFastMathToLLVM>;
+ VectorConvertToLLVMPattern<arith::MaximumFOp, LLVM::MaximumOp,
+ arith::AttrConvertFastMathToLLVM>;
using MaxNumFOpLowering =
- DenormalOpConversionToLLVMPattern<arith::MaxNumFOp, LLVM::MaxNumOp,
- arith::AttrConvertFastMathToLLVM>;
+ VectorConvertToLLVMPattern<arith::MaxNumFOp, LLVM::MaxNumOp,
+ arith::AttrConvertFastMathToLLVM>;
using MaxSIOpLowering =
VectorConvertToLLVMPattern<arith::MaxSIOp, LLVM::SMaxOp>;
using MaxUIOpLowering =
VectorConvertToLLVMPattern<arith::MaxUIOp, LLVM::UMaxOp>;
using MinimumFOpLowering =
- DenormalOpConversionToLLVMPattern<arith::MinimumFOp, LLVM::MinimumOp,
- arith::AttrConvertFastMathToLLVM>;
+ VectorConvertToLLVMPattern<arith::MinimumFOp, LLVM::MinimumOp,
+ arith::AttrConvertFastMathToLLVM>;
using MinNumFOpLowering =
- DenormalOpConversionToLLVMPattern<arith::MinNumFOp, LLVM::MinNumOp,
- arith::AttrConvertFastMathToLLVM>;
+ VectorConvertToLLVMPattern<arith::MinNumFOp, LLVM::MinNumOp,
+ arith::AttrConvertFastMathToLLVM>;
using MinSIOpLowering =
VectorConvertToLLVMPattern<arith::MinSIOp, LLVM::SMinOp>;
using MinUIOpLowering =
VectorConvertToLLVMPattern<arith::MinUIOp, LLVM::UMinOp>;
using MulFOpLowering =
- DenormalOpConversionToLLVMPattern<arith::MulFOp, LLVM::FMulOp,
- arith::AttrConvertFastMathToLLVM>;
+ VectorConvertToLLVMPattern<arith::MulFOp, LLVM::FMulOp,
+ arith::AttrConvertFastMathToLLVM>;
using MulIOpLowering =
VectorConvertToLLVMPattern<arith::MulIOp, LLVM::MulOp,
arith::AttrConvertOverflowToLLVM>;
using NegFOpLowering =
- DenormalOpConversionToLLVMPattern<arith::NegFOp, LLVM::FNegOp,
- arith::AttrConvertFastMathToLLVM>;
+ VectorConvertToLLVMPattern<arith::NegFOp, LLVM::FNegOp,
+ arith::AttrConvertFastMathToLLVM>;
using OrIOpLowering = VectorConvertToLLVMPattern<arith::OrIOp, LLVM::OrOp>;
using RemFOpLowering =
- DenormalOpConversionToLLVMPattern<arith::RemFOp, LLVM::FRemOp,
- arith::AttrConvertFastMathToLLVM>;
+ VectorConvertToLLVMPattern<arith::RemFOp, LLVM::FRemOp,
+ arith::AttrConvertFastMathToLLVM>;
using RemSIOpLowering =
VectorConvertToLLVMPattern<arith::RemSIOp, LLVM::SRemOp>;
using RemUIOpLowering =
@@ -158,8 +131,8 @@ using ShRUIOpLowering =
using SIToFPOpLowering =
VectorConvertToLLVMPattern<arith::SIToFPOp, LLVM::SIToFPOp>;
using SubFOpLowering =
- DenormalOpConversionToLLVMPattern<arith::SubFOp, LLVM::FSubOp,
- arith::AttrConvertFastMathToLLVM>;
+ VectorConvertToLLVMPattern<arith::SubFOp, LLVM::FSubOp,
+ arith::AttrConvertFastMathToLLVM>;
using SubIOpLowering =
VectorConvertToLLVMPattern<arith::SubIOp, LLVM::SubOp,
arith::AttrConvertOverflowToLLVM>;
diff --git a/mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td b/mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td
index 22c34b2bd42f58..6d7ac2be951dd7 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td
+++ b/mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td
@@ -422,11 +422,10 @@ def TruncIShrUIMulIToMulUIExtended :
//===----------------------------------------------------------------------===//
// mulf(negf(x), negf(y)) -> mulf(x,y)
-// (retain fastmath flags and denormal mode of the original divf)
+// (retain fastmath flags of original mulf)
def MulFOfNegF :
- Pat<(Arith_MulFOp (Arith_NegFOp $x, $_, $_),
- (Arith_NegFOp $y, $_, $_), $fmf, $mode),
- (Arith_MulFOp $x, $y, $fmf, $mode),
+ Pat<(Arith_MulFOp (Arith_NegFOp $x, $_), (Arith_NegFOp $y, $_), $fmf),
+ (Arith_MulFOp $x, $y, $fmf),
[(Constraint<CPred<"$0.getType() == $1.getType()">> $x, $y)]>;
//===----------------------------------------------------------------------===//
@@ -434,11 +433,10 @@ def MulFOfNegF :
//===----------------------------------------------------------------------===//
// divf(negf(x), negf(y)) -> divf(x,y)
-// (retain fastmath flags and denormal mode of the original divf)
+// (retain fastmath flags of original divf)
def DivFOfNegF :
- Pat<(Arith_DivFOp (Arith_NegFOp $x, $_, $_),
- (Arith_NegFOp $y, $_, $_), $fmf, $mode),
- (Arith_DivFOp $x, $y, $fmf, $mode),
+ Pat<(Arith_DivFOp (Arith_NegFOp $x, $_), (Arith_NegFOp $y, $_), $fmf),
+ (Arith_DivFOp $x, $y, $fmf),
[(Constraint<CPred<"$0.getType() == $1.getType()">> $x, $y)]>;
#endif // ARITH_PATTERNS
diff --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
index 700258a1b6254a..d8b314a3fa43c0 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
@@ -956,7 +956,7 @@ void arith::XOrIOp::getCanonicalizationPatterns(RewritePatternSet &patterns,
//===----------------------------------------------------------------------===//
OpFoldResult arith::NegFOp::fold(FoldAdaptor adaptor) {
- // negf(negf(x)) -> x
+ /// negf(negf(x)) -> x
if (auto op = this->getOperand().getDefiningOp<arith::NegFOp>())
return op.getOperand();
return constFoldUnaryOp<FloatAttr>(adaptor.getOperands(),
@@ -986,14 +986,6 @@ OpFoldResult arith::SubFOp::fold(FoldAdaptor adaptor) {
if (matchPattern(adaptor.getRhs(), m_PosZeroFloat()))
return getLhs();
- // Simplifies subf(x, rhs) to x if the following conditions are met:
- // 1. `rhs` is a denormal floating-point value.
- // 2. The denormal mode for the operation is set to positive zero.
- bool isPositiveZeroMode =
- getDenormalModeAttr().getValue() == DenormalMode::positive_zero;
- if (isPositiveZeroMode && matchPattern(adaptor.getRhs(), m_isDenormalFloat()))
- return getLhs();
-
return constFoldBinaryOp<FloatAttr>(
adaptor.getOperands(),
[](const APFloat &a, const APFloat &b) { return a - b; });
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index d9840e3923c4f7..8973e87c063b33 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -1498,17 +1498,15 @@ static Operation *findPayloadOp(Block *body, bool initFirst = false) {
void printShortForm(OpAsmPrinter &p, Operation *payloadOp) {
SmallVector<StringRef> elidedAttrs;
+ std::string attrToElide;
p << " { " << payloadOp->getName().getStringRef();
for (const auto &attr : payloadOp->getAttrs()) {
- if (auto fastAttr = dyn_cast<arith::FastMathFlagsAttr>(attr.getValue())) {
- if (fastAttr.getValue() == arith::FastMathFlags::none) {
- elidedAttrs.push_back(attr.getName());
- }
- }
- if (auto denormAttr = dyn_cast<arith::DenormalModeAttr>(attr.getValue())) {
- if (denormAttr.getValue() == arith::DenormalMode::ieee) {
- elidedAttrs.push_back(attr.getName());
- }
+ auto fastAttr =
+ llvm::dyn_cast<mlir::arith::FastMathFlagsAttr>(attr.getValue());
+ if (fastAttr && fastAttr.getValue() == mlir::arith::FastMathFlags::none) {
+ attrToElide = attr.getName().str();
+ elidedAttrs.push_back(attrToElide);
+ break;
}
}
p.printOptionalAttrDict(payloadOp->getAttrs(), elidedAttrs);
diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c
index fa3b0d894c995b..15a3a1fb50dc9e 100644
--- a/mlir/test/CAPI/ir.c
+++ b/mlir/test/CAPI/ir.c
@@ -320,7 +320,7 @@ int collectStats(MlirOperation operation) {
// clang-format off
// CHECK-LABEL: @stats
// CHECK: Number of operations: 12
- // CHECK: Number of attributes: 6
+ // CHECK: Number of attributes: 5
// CHECK: Number of blocks: 3
// CHECK: Number of regions: 3
// CHECK: Number of values: 9
diff --git a/mlir/test/Dialect/Arith/canonicalize.mlir b/mlir/test/Dialect/Arith/canonicalize.mlir
index f1e36c2707a8f0..6a186a0c6ceca0 100644
--- a/mlir/test/Dialect/Arith/canonicalize.mlir
+++ b/mlir/test/Dialect/Arith/canonicalize.mlir
@@ -3230,26 +3230,3 @@ func.func @bf16_fma(%arg0: vector<32x32x32xbf16>, %arg1: vector<32x32x32xbf16>,
}
}
#-}
-
-// -----
-
-// CHECK-LABEL: @test_fold_denorm
-// CHECK-SAME: %[[ARG0:.+]]: f32
-func.func @test_fold_denorm(%arg0: f32) -> f32 {
- // CHECK-NOT: arith.subf
- // CHECK: return %[[ARG0]] : f32
- %c_denorm = arith.constant 1.4e-45 : f32
- %sub = arith.subf %arg0, %c_denorm denormal<positive_zero> : f32
- return %sub : f32
-}
-
-// -----
-
-// CHECK-LABEL: @test_expect_not_to_fold_denorm
-func.func @test_expect_not_to_fold_denorm(%arg0: f32, %arg1 : f32) -> (f32, f32) {
- // CHECK-COUNT-2: arith.subf
- %c_denorm = arith.constant 1.4e-45 : f32
- %sub = arith.subf %arg0, %c_denorm denormal<ieee> : f32
- %sub_1 = arith.subf %arg1, %c_denorm denormal<preserve_sign> : f32
- return %sub, %sub_1 : f32, f32
-}
diff --git a/mlir/test/Dialect/Arith/ops.mlir b/mlir/test/Dialect/Arith/ops.mlir
index 5892e2a3d078c7..f684e02344a517 100644
--- a/mlir/test/Dialect/Arith/ops.mlir
+++ b/mlir/test/Dialect/Arith/ops.mlir
@@ -1161,75 +1161,3 @@ func.func @intflags_func(%arg0: i64, %arg1: i64) {
%3 = arith.shli %arg0, %arg1 overflow<nsw, nuw> : i64
return
}
-
-// CHECK-LABEL: check_denorm_modes(
-// CHECK-SAME: %[[ARG0:.+]]: f32, %[[ARG1:.+]]: f32, %[[ARG2:.+]]: f32)
-func.func @check_denorm_modes(%arg0: f32, %arg1: f32, %arg2: f32) {
- // CHECK: %[[CST:.+]] = arith.constant 1.401300e-45 : f32
- %c_denorm = arith.constant 1.4e-45 : f32
- // CHECK: %{{.+}} = arith.subf %{{.+}}, %{{.+}} denormal<preserve_sign> : f32
- %sub_preserve_sign = arith.subf %arg0, %c_denorm denormal<preserve_sign> : f32
- // CHECK: %{{.+}} = arith.subf %{{.+}}, %{{.+}} denormal<positive_zero> : f32
- %sub_positive_zero = arith.subf %arg1, %c_denorm denormal<positive_zero> : f32
- // CHECK: %{{.+}} = arith.subf %[[ARG2]], %[[CST]] : f32
- %sub_ieee = arith.subf %arg2, %c_denorm denormal<ieee> : f32
-
- // CHECK: %{{.+}} = arith.addf %{{.+}}, %{{.+}} denormal<preserve_sign> : f32
- %add_preserve_sign = arith.addf %arg0, %c_denorm denormal<preserve_sign> : f32
- // CHECK: %{{.+}} = arith.addf %{{.+}}, %{{.+}} denormal<positive_zero> : f32
- %add_positive_zero = arith.addf %arg1, %c_denorm denormal<positive_zero> : f32
- // CHECK: %{{.+}} = arith.addf %[[ARG2]], %[[CST]] : f32
- %add_ieee = arith.addf %arg2, %c_denorm denormal<ieee> : f32
-
- // CHECK: %{{.+}} = arith.mulf %{{.+}}, %{{.+}} denormal<preserve_sign> : f32
- %mul_preserve_sign = arith.mulf %arg0, %c_denorm denormal<preserve_sign> : f32
- // CHECK: %{{.+}} = arith.mulf %{{.+}}, %{{.+}} denormal<positive_zero> : f32
- %mul_positive_zero = arith.mulf %arg1, %c_denorm denormal<positive_zero> : f32
- // CHECK: %{{.+}} = arith.mulf %[[ARG2]], %[[CST]] : f32
- %mul_ieee = arith.mulf %arg2, %c_denorm denormal<ieee> : f32
-
- // CHECK: %{{.+}} = arith.divf %{{.+}}, %{{.+}} denormal<preserve_sign> : f32
- %div_preserve_sign = arith.divf %arg0, %c_denorm denormal<preserve_sign> : f32
- // CHECK: %{{.+}} = arith.divf %{{.+}}, %{{.+}} denormal<positive_zero> : f32
- %div_positive_zero = arith.divf %arg1, %c_denorm denormal<positive_zero> : f32
- // CHECK: %{{.+}} = arith.divf %[[ARG2]], %[[CST]] : f32
- %div_ieee = arith.divf %arg2, %c_denorm denormal<ieee> : f32
-
- // CHECK: %{{.+}} = arith.maximumf %{{.+}}, %{{.+}} denormal<preserve_sign> : f32
- %maximumf_preserve_sign = arith.maximumf %arg0, %c_denorm denormal<preserve_sign> : f32
- // CHECK: %{{.+}} = arith.maximumf %{{.+}}, %{{.+}} denormal<positive_zero> : f32
- %maximumf_positive_zero = arith.maximumf %arg1, %c_denorm denormal<positive_zero> : f32
- // CHECK: %{{.+}} = arith.maximumf %[[ARG2]], %[[CST]] : f32
- %maximumf_ieee = arith.maximumf %arg2, %c_denorm denormal<ieee> : f32
-
- // CHECK: %{{.+}} = arith.maxnumf %{{.+}}, %{{.+}} denormal<preserve_sign> : f32
- %maxnumf_preserve_sign = arith.maxnumf %arg0, %c_denorm denormal<preserve_sign> : f32
- // CHECK: %{{.+}} = arith.maxnumf %{{.+}}, %{{.+}} denormal<positive_zero> : f32
- %maxnumf_positive_zero = arith.maxnumf %arg1, %c_denorm denormal<positive_zero> : f32
- // CHECK: %{{.+}} = arith.maxnumf %[[ARG2]], %[[CST]] : f32
- %maxnumf_ieee = arith.maxnumf %arg2, %c_denorm denormal<ieee> : f32
-
- // CHECK: %{{.+}} = arith.minimumf %{{.+}}, %{{.+}} denormal<preserve_sign> : f32
- %minimumf_preserve_sign = arith.minimumf %arg0, %c_denorm denormal<preserve_sign> : f32
- // CHECK: %{{.+}} = arith.minimumf %{{.+}}, %{{.+}} denormal<positive_zero> : f32
- %minimumf_positive_zero = arith.minimumf %arg1, %c_denorm denormal<positive_zero> : f32
- // CHECK: %{{.+}} = arith.minimumf %[[ARG2]], %[[CST]] : f32
- %minimumf_ieee = arith.minimumf %arg2, %c_denorm denormal<ieee> : f32
-
- // CHECK: %{{.+}} = arith.minnumf %{{.+}}, %{{.+}} denormal<preserve_sign> : f32
- %minnumf_preserve_sign = arith.minnumf %arg0, %c_denorm denormal<preserve_sign> : f32
- // CHECK: %{{.+}} = arith.minnumf %{{.+}}, %{{.+}} denormal<positive_zero> : f32
- %minnumf_positive_zero = arith.minnumf %arg1, %c_denorm denormal<positive_zero> : f32
- // CHECK: %{{.+}} = arith.minnumf %[[ARG2]], %[[CST]] : f32
- %minnumf_ieee = arith.minnumf %arg2, %c_denorm denormal<ieee> : f32
-
-
- // CHECK: %{{.+}} = arith.negf %{{.+}} denormal<preserve_sign> : f32
- %negf_preserve_sign = arith.negf %arg0 denormal<preserve_sign> : f32
- // CHECK: %{{.+}} = arith.negf %{{.+}} denormal<positive_zero> : f32
- %negf_positive_sign = arith.negf %arg0 denormal<positive_zero> : f32
- // CHECK: %{{.+}} = arith.negf %[[ARG0]] : f32
- %negf_ieee = arith.negf %arg0 denormal<ieee> : f32
-
- return
-}
diff --git a/mlir/test/Dialect/Linalg/invalid.mlir b/mlir/test/Dialect/Linalg/invalid.mlir
index e3b6958cfa8816..a59472377a732c 100644
--- a/mlir/test/Dialect/Linalg/invalid.mlir
+++ b/mlir/test/Dialect/Linalg/invalid.mlir
@@ -270,7 +270,7 @@ func.func @generic_result_tensor_type(%arg0: memref<?xf32, affine_map<(i)[off]->
// -----
func.func @generic(%arg0: memref<?x?xf32>) {
- // expected-error @+6 {{block with no terminator, has %0 = "arith.addf"(%arg1, %arg1) <{denormal = #arith.denormal<ieee>, fastmath = #arith.fastmath<none>}> : (f32, f32) -> f32}}
+ // expected-error @+6 {{block with no terminator, has %0 = "arith.addf"(%arg1, %arg1) <{fastmath = #arith.fastmath<none>}> : (f32, f32) -> f32}}
linalg.generic {
indexing_maps = [ affine_map<(i, j) -> (i, j)> ],
iterator_types = ["parallel", "parallel"]}
More information about the Mlir-commits
mailing list