[ANALYSIS] Fix divisibility calculation for addptr (#1453)

This commit is contained in:
Keren Zhou
2023-03-31 17:57:31 -07:00
committed by GitHub
parent 859952a0aa
commit 801bb9d3b5
2 changed files with 71 additions and 5 deletions

View File

@@ -220,7 +220,16 @@ private:
// rhs = p * d_rhs = p * p' * gcd(d_lhs, d_rhs)
// lhs + rhs = k * d_lhs + p * d_rhs = (k * d_lhs + p * d_rhs) *
// gcd(d_lhs, d_rhs)
return gcd(lhs.getDivisibility(dim), rhs.getDivisibility(dim));
auto elemSize = 1;
if constexpr (std::is_same_v<OpTy, triton::AddPtrOp>) {
// %ptr = addptr %lhs, %rhs
// is equivalent to
// %0 = mul %lhs, %elemSize
// %ptr = add %0, %rhs
elemSize = std::max<unsigned int>(
1, triton::getPointeeBitWidth(op.getPtr().getType()) / 8);
}
return gcd(lhs.getDivisibility(dim), rhs.getDivisibility(dim) * elemSize);
}
int64_t getConstancy(OpTy op, const AxisInfo &lhs, const AxisInfo &rhs,