[sledge] Strengthen canonizer of Extract terms

Summary:
When extracting from a concatenation, drop a prefix of the concat with
length equal to the offset of the extraction:
```
(α₀^…^αᵢ^…) [0+n₀+…+nᵢ₋₁, l) ==> (αᵢ^…)[0,l) where nₓ ≡ |αₓ|
```

Reviewed By: jvillard

Differential Revision: D20192874

fbshipit-source-id: cd015aa36
master
Josh Berdine 5 years ago committed by Facebook Github Bot
parent 6a17078bec
commit 24c62fd39b

@ -741,6 +741,14 @@ let rec simp_extract agg off len =
| Ap2 (Memory, nJ, _) | Ap3 (Extract, _, _, nJ) -> ( | Ap2 (Memory, nJ, _) | Ap3 (Extract, _, _, nJ) -> (
let lIJ = simp_add2 lIJ nJ in let lIJ = simp_add2 lIJ nJ in
match (lIJ, len) with match (lIJ, len) with
(* (α₀^…^αᵢ^…) [0+n₀+…+nᵢ₋₁, l) ==> (αᵢ^…)[0,l)
where n |α| *)
| Integer {data= y}, Integer {data= z}
when Z.gt y z ->
let naIN =
Vector.sub ~pos:i ~len:(n - i) na1N
in
simp_extract (simp_concat naIN) zero len
| Integer {data= y}, Integer {data= z} | Integer {data= y}, Integer {data= z}
when Z.gt y z -> when Z.gt y z ->
Ap3 (Extract, agg, off, len) Ap3 (Extract, agg, off, len)

Loading…
Cancel
Save