File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -395,6 +395,13 @@ Definition arith_with_casts_rewrite_rulesT (adc_no_carry_to_add : bool) : list (
395
395
y ∈ ry -> y = Z.ones (Z.succ (Z.log2 y))
396
396
-> cstZ rv (cstZ ry ('y) &' cstZ rx x) = cstZ rx x)
397
397
]%Z%zrange
398
+ ; mymap
399
+ do_again
400
+ [ (forall c M rv r0 rM, 0 ∈ r0 -> M ∈ rM -> M ∈ rv -> 2^Z.log2 (M+1) = M + 1 -> 1 <= M ->
401
+ cstZ rv (Z.zselect (cstZ r[0~>1] c) (cstZ r0 ('0)) (cstZ rM ('M)))
402
+ = (dlet vc := cstZZ rv r[0~>1] (Z.sub_with_get_borrow_full ('(M+1)) (cstZ r[0~>1] c) 0 0) in
403
+ cstZ rv (fst vc)))
404
+ ]
398
405
; mymap
399
406
do_again
400
407
[ (* [do_again], so that we can trigger add/sub rules on the output *)
@@ -1213,7 +1220,8 @@ Section with_bitwidth.
1213
1220
:= Eval cbv [myapp mymap myflatten] in
1214
1221
mymap
1215
1222
dont_do_again
1216
- [(* no-op rule to prevent firing on selects between 0 and mask (since
1223
+ [
1224
+ (* no-op rule to prevent firing on selects between 0 and mask (since
1217
1225
these can be succinctly expressed as 0-c *)
1218
1226
(forall rc c,
1219
1227
singlewidth (Z.zselect (cstZ rc c)
Original file line number Diff line number Diff line change @@ -571,6 +571,11 @@ Proof using Type.
571
571
all: repeat interp_good_t_step_arith.
572
572
all: remove_casts; try fin_with_nia.
573
573
all: try (reflect_hyps; lia).
574
+
575
+ { (* cmov c 0 -1 -> sbb 0 0 c *)
576
+ enough (- c mod (M + 1) = M) as E by (rewrite E; remove_casts; trivial).
577
+ match goal with H5 : _ |- _ => apply unfold_is_bounded_by_bool in H5; cbn in H5 end.
578
+ rewrite Z.mod_opp_l_nz; rewrite ?Z.mod_small; nia. }
574
579
Qed .
575
580
576
581
Lemma strip_literal_casts_rewrite_rules_proofs
You can’t perform that action at this time.
0 commit comments