Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 4961247

Browse files
author
Sven Verdoolaege
committed
reduction_matcher.cc: affInvolvesOnlyDim: ignore parameters
Referencing a parameter should not affect whether a schedule band member can be considered a reduction since a parameter represents a constant (if unknown) value. What is important is that the band member does not involve any non-reduction statement indices.
1 parent 804fdf5 commit 4961247

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/core/polyhedral/reduction_matcher.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ bool isReductionUpdateId(
7272
return false;
7373
}
7474

75-
bool affInvolvesOnlyDim(isl::aff aff, int redDimIdx) {
75+
/*
76+
* Does "aff" only involve the specified input dimension (and not
77+
* any other input dimensions).
78+
*/
79+
bool affInvolvesOnlyInputDim(isl::aff aff, int redDimIdx) {
7680
auto space = aff.get_space();
7781

7882
bool hasPureDim = aff.involves_dims(isl::dim_type::in, redDimIdx, 1);
@@ -85,7 +89,7 @@ bool affInvolvesOnlyDim(isl::aff aff, int redDimIdx) {
8589
if (aff.get_coefficient_val(isl::dim_type::div, i).is_zero()) {
8690
continue;
8791
}
88-
bool divR = affInvolvesOnlyDim(aff.get_div(i), redDimIdx);
92+
bool divR = affInvolvesOnlyInputDim(aff.get_div(i), redDimIdx);
8993
divsInvolveDim |=
9094
divR; // becomes true if at least one involves the given dim
9195
divsInvolveOtherDims |=
@@ -96,9 +100,7 @@ bool affInvolvesOnlyDim(isl::aff aff, int redDimIdx) {
96100
aff.involves_dims(
97101
isl::dim_type::in,
98102
redDimIdx + 1,
99-
space.dim(isl::dim_type::in) - redDimIdx - 1) ||
100-
aff.involves_dims(
101-
isl::dim_type::param, 0, space.dim(isl::dim_type::param));
103+
space.dim(isl::dim_type::in) - redDimIdx - 1);
102104

103105
if (involvesOtherDims) {
104106
return false;
@@ -136,7 +138,7 @@ bool isAlmostIdentityReduction(isl::pw_aff pa, const Scop& scop) {
136138

137139
auto aff = paWrapper[0].second;
138140
for (auto redDimIdx : reductionDims) {
139-
if (affInvolvesOnlyDim(aff, redDimIdx)) {
141+
if (affInvolvesOnlyInputDim(aff, redDimIdx)) {
140142
return true;
141143
}
142144
}

0 commit comments

Comments
 (0)