[Mlir-commits] [mlir] [mlir][dataflow] Fix for integer range analysis propagation bug (PR #93199)

Felix Schneider llvmlistbot at llvm.org
Thu May 23 23:22:33 PDT 2024


================
@@ -46,243 +45,271 @@ void arith::ConstantOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
 // AddIOp
 //===----------------------------------------------------------------------===//
 
-void arith::AddIOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
+void arith::AddIOp::inferResultRanges(ArrayRef<OptionalIntRanges> argRanges,
                                       SetIntRangeFn setResultRange) {
-  setResultRange(getResult(), inferAdd(argRanges, convertArithOverflowFlags(
-                                                      getOverflowFlags())));
+  auto infer = inferFromOptionals([this](ArrayRef<ConstantIntRanges> ranges) {
+    return inferAdd(ranges, convertArithOverflowFlags(getOverflowFlags()));
+  });
+
+  setResultRange(getResult(), infer(argRanges));
 }
 
 //===----------------------------------------------------------------------===//
 // SubIOp
 //===----------------------------------------------------------------------===//
 
-void arith::SubIOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
+void arith::SubIOp::inferResultRanges(ArrayRef<OptionalIntRanges> argRanges,
                                       SetIntRangeFn setResultRange) {
-  setResultRange(getResult(), inferSub(argRanges, convertArithOverflowFlags(
-                                                      getOverflowFlags())));
+  auto infer = inferFromOptionals([this](ArrayRef<ConstantIntRanges> ranges) {
+    return inferSub(ranges, convertArithOverflowFlags(getOverflowFlags()));
+  });
+
+  setResultRange(getResult(), infer(argRanges));
 }
 
 //===----------------------------------------------------------------------===//
 // MulIOp
 //===----------------------------------------------------------------------===//
 
-void arith::MulIOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
+void arith::MulIOp::inferResultRanges(ArrayRef<OptionalIntRanges> argRanges,
                                       SetIntRangeFn setResultRange) {
-  setResultRange(getResult(), inferMul(argRanges, convertArithOverflowFlags(
-                                                      getOverflowFlags())));
+  auto infer = inferFromOptionals([this](ArrayRef<ConstantIntRanges> ranges) {
----------------
ubfx wrote:

Could passing a lambda as `function_ref` be a  problem? I think I tried something like this and it caused crashes on some compilers/platforms, maybe this is the reason for the MSVC build failure?

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


More information about the Mlir-commits mailing list