@@ -175,37 +175,31 @@ module ModulusAnalysis<
175175 private predicate phiModulusRankStep (
176176 Sem:: SsaPhiNode phi , Bounds:: SemBound b , int val , int mod , int rix
177177 ) {
178- /*
179- * base case. If any phi input is equal to `b + val` modulo `mod`, that's a potential congruence
180- * class for the phi node.
181- */
182-
178+ // Base case. If any phi input is equal to `b + val` modulo `mod`, that's a
179+ // potential congruence class for the phi node.
183180 rix = 0 and
184181 phiModulusInit ( phi , b , val , mod )
185182 or
186183 exists ( Sem:: SsaVariable inp , Sem:: SsaReadPositionPhiInputEdge edge , int v1 , int m1 |
187184 mod != 1 and
188185 val = remainder ( v1 , mod )
189186 |
190- /*
191- * Recursive case. If `inp` = `b + v2` mod `m2`, we combine that with the preceding potential
192- * congruence class `b + v1` mod `m1`. The result will be the congruence class of `v1 ` modulo
193- * the greatest common denominator of `m1`, `m2`, and `v1 - v2`.
194- */
195-
187+ // Recursive case. If `inp` = `b + v2` modulo `m2`, we combine that with
188+ // the preceding potential congruence class `b + v1` modulo `m1`. In order
189+ // to represent the result as a single congruence class `b + v ` modulo
190+ // `mod`, we must have that `mod` divides both `m1` and `m2` and that `v1`
191+ // equals `v2` modulo `mod`. The largest value of `mod` that satisfies
192+ // this is the greatest common divisor of `m1`, `m2`, and `v1 - v2`.
196193 exists ( int v2 , int m2 |
197194 U:: rankedPhiInput ( pragma [ only_bind_out ] ( phi ) , inp , edge , rix ) and
198195 phiModulusRankStep ( phi , b , v1 , m1 , rix - 1 ) and
199196 ssaModulus ( inp , edge , b , v2 , m2 ) and
200197 mod = m1 .gcd ( m2 ) .gcd ( v1 - v2 )
201198 )
202199 or
203- /*
204- * Recursive case. If `inp` = `phi` mod `m2`, we combine that with the preceding potential
205- * congruence class `b + v1` mod `m1`. The result will be a congruence class modulo the greatest
206- * common denominator of `m1` and `m2`.
207- */
208-
200+ // Recursive case. If `inp` = `phi` mod `m2`, we combine that with the
201+ // preceding potential congruence class `b + v1` mod `m1`. The result will be
202+ // the congruence class modulo the greatest common divisor of `m1` and `m2`.
209203 exists ( int m2 |
210204 U:: rankedPhiInput ( phi , inp , edge , rix ) and
211205 phiModulusRankStep ( phi , b , v1 , m1 , rix - 1 ) and
0 commit comments