@@ -175,37 +175,31 @@ module ModulusAnalysis<
175
175
private predicate phiModulusRankStep (
176
176
Sem:: SsaPhiNode phi , Bounds:: SemBound b , int val , int mod , int rix
177
177
) {
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.
183
180
rix = 0 and
184
181
phiModulusInit ( phi , b , val , mod )
185
182
or
186
183
exists ( Sem:: SsaVariable inp , Sem:: SsaReadPositionPhiInputEdge edge , int v1 , int m1 |
187
184
mod != 1 and
188
185
val = remainder ( v1 , mod )
189
186
|
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`.
196
193
exists ( int v2 , int m2 |
197
194
U:: rankedPhiInput ( pragma [ only_bind_out ] ( phi ) , inp , edge , rix ) and
198
195
phiModulusRankStep ( phi , b , v1 , m1 , rix - 1 ) and
199
196
ssaModulus ( inp , edge , b , v2 , m2 ) and
200
197
mod = m1 .gcd ( m2 ) .gcd ( v1 - v2 )
201
198
)
202
199
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`.
209
203
exists ( int m2 |
210
204
U:: rankedPhiInput ( phi , inp , edge , rix ) and
211
205
phiModulusRankStep ( phi , b , v1 , m1 , rix - 1 ) and
0 commit comments