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
6 changes: 5 additions & 1 deletion lib/Analysis/AxisInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,12 @@ class SelectOpAxisInfoVisitor final : public AxisInfoVisitorImpl<OpTy> {
rhsInfo.getConstancy(d), condConstancy[d]));
contiguity.push_back(gcd(lhsInfo.getContiguity(d),
rhsInfo.getContiguity(d), condConstancy[d]));
// getDivisibilityFromContiguity does not see condConstancy; clamp
// by the just-computed output contiguity so the result remains
// sound when condConstancy reduces it below the input contiguities.
divisibility.push_back(
getDivisibilityFromContiguity(lhsInfo, rhsInfo, d));
gcd(getDivisibilityFromContiguity(lhsInfo, rhsInfo, d),
contiguity.back()));
}
}
if (lhsInfo.getConstantValue().has_value() &&
Expand Down
18 changes: 18 additions & 0 deletions test/Analysis/test-alignment.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,24 @@ tt.func @select_same_value_constancy() {

// -----

// Regression: SelectOp must clamp divisibility when condConstancy reduces the
// output contiguity below either input's contiguity. Otherwise the helper
// getDivisibilityFromContiguity overestimates divisibility because it does not
// see condConstancy. See issue triton-lang/triton#10067.
tt.func @select_cond_constancy_clamps_divisibility(%arg0: tensor<8xi1>) {
// expected-remark @below {{contiguity = [8], divisibility = [8], constancy = [1], constant_value = <none>}}
%lhs = tt.make_range {end = 16 : i32, start = 8 : i32} : tensor<8xi32>
// expected-remark @below {{contiguity = [8], divisibility = [16], constancy = [1], constant_value = <none>}}
%rhs = tt.make_range {end = 24 : i32, start = 16 : i32} : tensor<8xi32>
// %arg0 has unknown contents, so condConstancy = 1. Output contiguity must
// collapse to gcd(8, 8, 1) = 1; divisibility must clamp to 1 (not gcd(8, 16) = 8).
// expected-remark @below {{contiguity = [1], divisibility = [1], constancy = [1], constant_value = <none>}}
%sel = arith.select %arg0, %lhs, %rhs : tensor<8xi1>, tensor<8xi32>
tt.return
}

// -----

tt.func @cmp_after_max_constancy() {
%c5 = arith.constant dense<5> : tensor<4xi32>
%c7 = arith.constant dense<7> : tensor<4xi32>
Expand Down
Loading