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
2 changes: 2 additions & 0 deletions mlir/lib/Interfaces/InferIntRangeInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "mlir/Interfaces/InferIntRangeInterface.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Interfaces/InferIntRangeInterface.cpp.inc"
#include <optional>

Expand All @@ -28,6 +29,7 @@ const APInt &ConstantIntRanges::smin() const { return sminVal; }
const APInt &ConstantIntRanges::smax() const { return smaxVal; }

unsigned ConstantIntRanges::getStorageBitwidth(Type type) {
type = getElementTypeOrSelf(type);
if (type.isIndex())
return IndexType::kInternalStorageBitWidth;
if (auto integerType = dyn_cast<IntegerType>(type))
Expand Down
11 changes: 10 additions & 1 deletion mlir/test/Dialect/Vector/int-range-interface.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,20 @@ func.func @vector_insertelement() -> vector<4xindex> {

// CHECK-LABEL: func @test_loaded_vector_extract
// No bounds
// CHECK: test.reflect_bounds %{{.*}} : i32
// CHECK: test.reflect_bounds {smax = 2147483647 : si32, smin = -2147483648 : si32, umax = 4294967295 : ui32, umin = 0 : ui32} %{{.*}} : i32
func.func @test_loaded_vector_extract(%memref : memref<16xi32>) -> i32 {
%c0 = arith.constant 0 : index
%v = vector.load %memref[%c0] : memref<16xi32>, vector<4xi32>
%e = vector.extract %v[0] : i32 from vector<4xi32>
%bounds = test.reflect_bounds %e : i32
func.return %bounds : i32
}

// CHECK-LABEL: func @test_vector_extsi
// CHECK: test.reflect_bounds {smax = 5 : si32, smin = 1 : si32, umax = 5 : ui32, umin = 1 : ui32}
func.func @test_vector_extsi() -> vector<2xi32> {
%0 = test.with_bounds {smax = 5 : si8, smin = 1 : si8, umax = 5 : ui8, umin = 1 : ui8 } : vector<2xi8>
%1 = arith.extsi %0 : vector<2xi8> to vector<2xi32>
%2 = test.reflect_bounds %1 : vector<2xi32>
func.return %2 : vector<2xi32>
}
Loading