@@ -72,43 +72,25 @@ bool isReductionUpdateId(
72
72
return false ;
73
73
}
74
74
75
- bool affInvolvesOnlyDim (isl::aff aff, int redDimIdx) {
76
- auto space = aff.get_space ();
77
-
78
- bool hasPureDim = aff.involves_dims (isl::dim_type::in, redDimIdx, 1 );
79
-
80
- bool divsInvolveOtherDims = false ;
81
- bool divsInvolveDim = false ;
82
- for (int i = 0 , ei = aff.dim (isl::dim_type::div); i < ei; ++i) {
83
- // Ignore divs with coefficient 0 that may be referred to by the aff.
84
- // This is particularly the case when we are already processing the div.
85
- if (aff.get_coefficient_val (isl::dim_type::div, i).is_zero ()) {
86
- continue ;
87
- }
88
- bool divR = affInvolvesOnlyDim (aff.get_div (i), redDimIdx);
89
- divsInvolveDim |=
90
- divR; // becomes true if at least one involves the given dim
91
- divsInvolveOtherDims |=
92
- !divR; // becomes true if at least one involves other dims
75
+ /*
76
+ * Does "aff" only involve the specified input dimension (and not
77
+ * any other input dimensions).
78
+ */
79
+ bool pwAffInvolvesOnlyInputDim (isl::pw_aff pa, int redDimIdx) {
80
+ auto space = pa.get_space ();
81
+
82
+ if (!pa.involves_dims (isl::dim_type::in, redDimIdx, 1 )) {
83
+ return false ;
93
84
}
94
85
95
- bool involvesOtherDims = aff .involves_dims (isl::dim_type::in, 0 , redDimIdx) ||
96
- aff .involves_dims (
86
+ if (pa .involves_dims (isl::dim_type::in, 0 , redDimIdx) ||
87
+ pa .involves_dims (
97
88
isl::dim_type::in,
98
89
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));
102
-
103
- if (involvesOtherDims) {
104
- return false ;
105
- }
106
- if (!hasPureDim && !divsInvolveDim) {
107
- return false ;
108
- }
109
- if (divsInvolveDim && divsInvolveOtherDims) {
90
+ space.dim (isl::dim_type::in) - redDimIdx - 1 )) {
110
91
return false ;
111
92
}
93
+
112
94
return true ;
113
95
}
114
96
@@ -129,14 +111,8 @@ bool isAlmostIdentityReduction(isl::pw_aff pa, const Scop& scop) {
129
111
return false ;
130
112
}
131
113
132
- auto paWrapper = isl::PA (pa);
133
- if (paWrapper.size () != 1 ) {
134
- return false ;
135
- }
136
-
137
- auto aff = paWrapper[0 ].second ;
138
114
for (auto redDimIdx : reductionDims) {
139
- if (affInvolvesOnlyDim (aff , redDimIdx)) {
115
+ if (pwAffInvolvesOnlyInputDim (pa , redDimIdx)) {
140
116
return true ;
141
117
}
142
118
}
0 commit comments