You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both prim/41N and prim/32N are equal to Is_int x/29UV, and prim/32N dominates prim/41N, so I'd expect CSE to kick in and eliminate prim/41N, but evidently it does not.
The text was updated successfully, but these errors were encountered:
I looked into this, and the issue is during the CSE join.
We have two branches with the same CSE equation (Is_int x/29 = prim/32), but in one of them we also know that x/29 = 0. Since we canonicalise our primitives at each use, this turns into a join between Is_int 0 on one side and Is_int x/29 on the other side, the result being then empty.
In this particular example, canonicalising with the typing env at fork instead solves our problem, but we lose cases where each branch has a local alias of a common variable.
We could instead add CSE equations for every primitive that is equivalent to the current one up to aliases, but that will likely blow up quickly.
I think I will propose a middle-ground solution: for each CSE primitive, generate two primitives (one with the arguments canonicalised in the env at fork, one canonicalised in the env at use), and if they differ add both to the set of eligible primitives.
On current
main
(ab2272b) with the following code:I get the following output in
-dflambda
:Both
prim/41N
andprim/32N
are equal toIs_int x/29UV
, andprim/32N
dominatesprim/41N
, so I'd expect CSE to kick in and eliminateprim/41N
, but evidently it does not.The text was updated successfully, but these errors were encountered: