[Mlir-commits] [mlir] [mlir][LLVM] Add nsw and nuw flags (PR #74508)

Tobias Gysi llvmlistbot at llvm.org
Tue Dec 5 12:57:51 PST 2023


================
@@ -62,14 +62,23 @@ static auto processFMFAttr(ArrayRef<NamedAttribute> attrs) {
   return filteredAttrs;
 }
 
+static auto processIntArithAttr(ArrayRef<NamedAttribute> attrs) {
+  SmallVector<NamedAttribute, 8> filteredAttrs(
+      llvm::make_filter_range(attrs, [&](NamedAttribute attr) {
+        return attr.getName() != "arithFlags";
+      }));
+  return filteredAttrs;
+}
+
 static ParseResult parseLLVMOpAttrs(OpAsmParser &parser,
                                     NamedAttrList &result) {
   return parser.parseOptionalAttrDict(result);
 }
 
 static void printLLVMOpAttrs(OpAsmPrinter &printer, Operation *op,
                              DictionaryAttr attrs) {
-  printer.printOptionalAttrDict(processFMFAttr(attrs.getValue()));
+  printer.printOptionalAttrDict(
+      processFMFAttr(processIntArithAttr(attrs.getValue())));
----------------
gysit wrote:

```suggestion
  printer.printOptionalAttrDict(
      processFMFAttr(attrs.getValue()),
      /*elidedAttrs=*/{IntegerArithFlagsInterface::getIntegerArithAttrName()});
```
Could we add the attribute to the elided attributes to avoid the need for the extra function above? 

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


More information about the Mlir-commits mailing list