[Mlir-commits] [mlir] [mlir][arith] Fix canon pattern for large ints in chained arith (PR #68900)

Markus Böck llvmlistbot at llvm.org
Thu Oct 12 11:53:32 PDT 2023


================
@@ -39,26 +39,35 @@ using namespace mlir::arith;
 static IntegerAttr
 applyToIntegerAttrs(PatternRewriter &builder, Value res, Attribute lhs,
                     Attribute rhs,
-                    function_ref<int64_t(int64_t, int64_t)> binFn) {
-  return builder.getIntegerAttr(res.getType(),
-                                binFn(llvm::cast<IntegerAttr>(lhs).getInt(),
-                                      llvm::cast<IntegerAttr>(rhs).getInt()));
+                    function_ref<APInt(APInt, APInt&)> binFn) {
+  auto lhsVal = llvm::cast<IntegerAttr>(lhs).getValue();
+  auto rhsVal = llvm::cast<IntegerAttr>(rhs).getValue();
+  auto value = binFn(lhsVal, rhsVal);
----------------
zero9178 wrote:

Could we write out the `auto` types here? MLIR style is to not use `auto` unless the type already appears in the expression and is therefore obvious (e.g. a `cast`) or the type is hard to spell.
`lhsVal` and `rhsVal` shoul also be const references again to avoid copies.

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


More information about the Mlir-commits mailing list