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
4 changes: 2 additions & 2 deletions mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ mlir::intrange::inferRemU(ArrayRef<ConstantIntRanges> argRanges) {

unsigned width = rhsMin.getBitWidth();
APInt umin = APInt::getZero(width);
APInt umax = APInt::getMaxValue(width);
// Remainder can't be larger than either of its arguments.
APInt umax = llvm::APIntOps::umin((rhsMax - 1), lhs.umax());

if (!rhsMin.isZero()) {
umax = rhsMax - 1;
// Special case: sweeping out a contiguous range in N/[modulus]
if (rhsMin == rhsMax) {
const APInt &lhsMin = lhs.umin(), &lhsMax = lhs.umax();
Expand Down
13 changes: 13 additions & 0 deletions mlir/test/Dialect/Arith/int-range-interface.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ func.func @remui_base(%arg0 : index, %arg1 : index ) -> i1 {
func.return %3 : i1
}

// CHECK-LABEL: func @remui_base_maybe_zero
// CHECK: %[[true:.*]] = arith.constant true
// CHECK: return %[[true]]
func.func @remui_base_maybe_zero(%arg0 : index, %arg1 : index ) -> i1 {
%c4 = arith.constant 4 : index
%c5 = arith.constant 5 : index

%0 = arith.minui %arg1, %c4 : index
%1 = arith.remui %arg0, %0 : index
%2 = arith.cmpi ult, %1, %c5 : index
func.return %2 : i1
}

// CHECK-LABEL: func @remsi_base
// CHECK: %[[ret:.*]] = arith.cmpi sge
// CHECK: return %[[ret]]
Expand Down
Loading