@@ -72,43 +72,25 @@ bool isReductionUpdateId(
7272 return false ;
7373}
7474
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 ;
9384 }
9485
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 (
9788 isl::dim_type::in,
9889 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 )) {
11091 return false ;
11192 }
93+
11294 return true ;
11395}
11496
@@ -129,14 +111,8 @@ bool isAlmostIdentityReduction(isl::pw_aff pa, const Scop& scop) {
129111 return false ;
130112 }
131113
132- auto paWrapper = isl::PA (pa);
133- if (paWrapper.size () != 1 ) {
134- return false ;
135- }
136-
137- auto aff = paWrapper[0 ].second ;
138114 for (auto redDimIdx : reductionDims) {
139- if (affInvolvesOnlyDim (aff , redDimIdx)) {
115+ if (pwAffInvolvesOnlyInputDim (pa , redDimIdx)) {
140116 return true ;
141117 }
142118 }
0 commit comments