[Mlir-commits] [mlir] [mlir] IntegerRangeAnalysis: add support for vector type (PR #112292)
Ivan Butygin
llvmlistbot at llvm.org
Thu Oct 31 16:19:16 PDT 2024
================
@@ -35,10 +35,27 @@ convertArithOverflowFlags(arith::IntegerOverflowFlags flags) {
void arith::ConstantOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
SetIntRangeFn setResultRange) {
- auto constAttr = llvm::dyn_cast_or_null<IntegerAttr>(getValue());
- if (constAttr) {
+ if (auto constAttr = llvm::dyn_cast_or_null<IntegerAttr>(getValue())) {
const APInt &value = constAttr.getValue();
setResultRange(getResult(), ConstantIntRanges::constant(value));
+ return;
+ }
+ if (auto constAttr =
+ llvm::dyn_cast_or_null<DenseIntElementsAttr>(getValue())) {
+ std::optional<ConstantIntRanges> result;
+ for (APInt &&val : constAttr) {
+ auto range = ConstantIntRanges::constant(val);
+ if (!result) {
+ result = range;
+ } else {
+ result = result->rangeUnion(range);
+ }
+ }
+
+ if (result)
----------------
Hardcode84 wrote:
This should never trigger as 0-element vectors are not suported. Changed to assert.
https://github.com/llvm/llvm-project/pull/112292
More information about the Mlir-commits
mailing list