Skip to content
Closed
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
8 changes: 6 additions & 2 deletions mlir/lib/Dialect/Affine/IR/AffineOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4932,8 +4932,12 @@ foldCstValueToCstAttrBasis(ArrayRef<OpFoldResult> mixedBasis,
MutableOperandRange mutableDynamicBasis,
ArrayRef<Attribute> dynamicBasis) {
uint64_t dynamicBasisIndex = 0;
for (OpFoldResult basis : dynamicBasis) {
if (basis) {
for (Attribute basis : dynamicBasis) {
// Skip poison values: they don't have a concrete integer value, so erasing
// them from the dynamic operands would create an inconsistency between
// the static basis (which would still hold kDynamic) and the dynamic
// operand list (which would be one element shorter).
if (basis && !isa<ub::PoisonAttr>(basis)) {
mutableDynamicBasis.erase(dynamicBasisIndex);
} else {
++dynamicBasisIndex;
Expand Down
12 changes: 12 additions & 0 deletions mlir/test/Dialect/Affine/canonicalize.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,18 @@ func.func @linearize_dont_fold_dynamic_basis(%arg0: index) -> index {

// -----

// Folding a linearize_index with a ub.poison basis must not crash.
// CHECK-LABEL: @linearize_dont_fold_poison_basis
// CHECK: %[[RET:.+]] = affine.linearize_index
// CHECK: return %[[RET]]
func.func @linearize_dont_fold_poison_basis(%arg0: index, %arg1: index) -> index {
%poison = ub.poison : index
%ret = affine.linearize_index [%arg0, %arg1] by (%poison) : index
return %ret : index
}

// -----

// CHECK-LABEL: func @cancel_delinearize_linearize_disjoint_exact(
// CHECK-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index,
// CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index,
Expand Down