Skip to content

[mlir] IntegerRangeAnalysis: return initialized state for noninteger values #133541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2025
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: 0 additions & 3 deletions mlir/lib/Interfaces/InferIntRangeInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ raw_ostream &mlir::operator<<(raw_ostream &os, const ConstantIntRanges &range) {

IntegerValueRange IntegerValueRange::getMaxRange(Value value) {
unsigned width = ConstantIntRanges::getStorageBitwidth(value.getType());
if (width == 0)
return {};

APInt umin = APInt::getMinValue(width);
APInt umax = APInt::getMaxValue(width);
APInt smin = width != 0 ? APInt::getSignedMinValue(width) : umin;
Expand Down
18 changes: 17 additions & 1 deletion mlir/test/Dialect/Arith/int-range-interface.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: mlir-opt -int-range-optimizations -canonicalize %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -int-range-optimizations -canonicalize %s | FileCheck %s

// CHECK-LABEL: func @add_min_max
// CHECK: %[[c3:.*]] = arith.constant 3 : index
Expand Down Expand Up @@ -1013,3 +1013,19 @@ func.func @zero_trip_loop2() {
}
return
}

// CHECK-LABEL: @noninteger_operation_result
func.func @noninteger_operation_result(%lb: index, %ub: index, %step: index, %cond: i1) {
%c1_i32 = arith.constant 1 : i32

%0 = "some_fp_op"() : () -> f32
// CHECK: [[OUTS:%.*]]:2 = scf.for
%outs:2 = scf.for %i = %lb to %ub step %step iter_args(%a = %c1_i32, %b = %0) -> (i32, f32) {
%1 = "some_int_op"() : () -> i32
scf.yield %1, %0 : i32, f32
}

%result = arith.select %cond, %c1_i32, %outs#0 : i32
"use"(%result) : (i32) -> ()
return
}
Loading