[Mlir-commits] [mlir] 93f081c - [mlir] Avoid crash of UnsignedWhenEquivalent for no integer type.
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Jan 9 18:05:11 PST 2023
Author: jacquesguan
Date: 2023-01-10T10:05:02+08:00
New Revision: 93f081c896536112e1ca8133991d23cb1134793a
URL: https://github.com/llvm/llvm-project/commit/93f081c896536112e1ca8133991d23cb1134793a
DIFF: https://github.com/llvm/llvm-project/commit/93f081c896536112e1ca8133991d23cb1134793a.diff
LOG: [mlir] Avoid crash of UnsignedWhenEquivalent for no integer type.
Fixes https://github.com/llvm/llvm-project/issues/59617.
Reviewed By: Mogball
Differential Revision: https://reviews.llvm.org/D141038
Added:
Modified:
mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
mlir/test/Dialect/Arith/unsigned-when-equivalent.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
index 84311e47ef8c7..f03ac019fd011 100644
--- a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
@@ -25,6 +25,8 @@ using namespace mlir::dataflow;
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;
diff --git a/mlir/test/Dialect/Arith/unsigned-when-equivalent.mlir b/mlir/test/Dialect/Arith/unsigned-when-equivalent.mlir
index bbec4a1e7d5db..63d7dc739a9e0 100644
--- a/mlir/test/Dialect/Arith/unsigned-when-equivalent.mlir
+++ b/mlir/test/Dialect/Arith/unsigned-when-equivalent.mlir
@@ -96,3 +96,12 @@ func.func @dead_code() {
%1 = arith.floordivsi %0, %0 : i8
return
}
+
+// Make sure not crash.
+// CHECK-LABEL: @no_integer_or_index
+func.func @no_integer_or_index() {
+ // CHECK: arith.cmpi
+ %cst_0 = arith.constant dense<[0]> : vector<1xi32>
+ %cmp = arith.cmpi slt, %cst_0, %cst_0 : vector<1xi32>
+ return
+}
More information about the Mlir-commits
mailing list