Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ static ConstantIntRanges inferDivURange(const ConstantIntRanges &lhs,
DivisionFixupFn fixup) {
const APInt &lhsMin = lhs.umin(), &lhsMax = lhs.umax(), &rhsMin = rhs.umin(),
&rhsMax = rhs.umax();

if (!rhsMin.isZero()) {
if (!rhsMin.isZero() && !rhsMax.isZero()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition should be strictly redundant - can you debug why you have this case?

auto udiv = [&fixup](const APInt &a,
const APInt &b) -> std::optional<APInt> {
return fixup(a, b, a.udiv(b));
Expand Down
9 changes: 9 additions & 0 deletions mlir/test/Dialect/Arith/int-range-interface.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ func.func @ceil_divui(%arg0 : index) -> i1 {
func.return %7 : i1
}

// CHECK-LABEL: func @ceil_divui_by_zero_issue_131273
// CHECK-NEXT: return
func.func @ceil_divui_by_zero_issue_131273() {
%0 = test.with_bounds {smax = 0 : i32, smin = -1 : i32, umax = 0 : i32, umin = -1 : i32} : i32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix this rest so that umin <=(unsigned) umax?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix this test so that umin <=(unsigned) umax?

%c7_i32 = arith.constant 7 : i32
%1 = arith.ceildivui %c7_i32, %0 : i32
return
}

// CHECK-LABEL: func @ceil_divsi
// CHECK: %[[ret:.*]] = arith.cmpi eq
// CHECK: return %[[ret]]
Expand Down