Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asm equivalence checker should handle: (neg 64, [9]) ≠ (slice 0 64, [(negZ, [9])]) #2050

Open
JasonGross opened this issue Mar 11, 2025 · 2 comments · May be fixed by #2059
Open

Asm equivalence checker should handle: (neg 64, [9]) ≠ (slice 0 64, [(negZ, [9])]) #2050

JasonGross opened this issue Mar 11, 2025 · 2 comments · May be fixed by #2059

Comments

@JasonGross
Copy link
Collaborator

No description provided.

@JasonGross
Copy link
Collaborator Author

Example (remove the extra newline and click synthesize again)

I see

Unable to unify: [inr [626, 631, 636, 641, 646]] == [inr [17, 24, 30, 36, 42]]
Could not unify the values at index 0: [#626, #631, #636, #641, #646] ≠ [#17, #24, #30, #36, #42]
index 0: #626 ≠ #17
(add 64, [#4, #11, #625]) ≠ (add 64, [#4, #11, #16])
index 2: #625 ≠ #16
(neg 64, [#9]) ≠ (slice 0 64, [#14])
(neg 64, [(old 64 9, [])]) ≠ (slice 0 64, [(negZ, [9])])
Operation mismatch: neg 64 ≠ slice 0 64

But we have

Definition slice0 (d : dag) :=
fun e => match e with
ExprApp (slice 0 s, [(ExprApp ((addZ|mulZ|negZ|shlZ|shrZ|andZ|orZ|xorZ) as o, args))]) =>
ExprApp ((match o with addZ=>add s|mulZ=>mul s|negZ=>neg s|shlZ=>shl s|shrZ => shr s|andZ => and s| orZ => or s|xorZ => xor s |_=>old 0%N 999999%N end), args)
| _ => e end.
#[local] Instance describe_slice0 : description_of Rewrite.slice0
:= "Merges (slice 0 s) into addZ,mulZ,negZ,shlZ,shrZ,andZ,orZ,xorZ".

which seems like it should be triggering on the RHS (PHOAS)...

@JasonGross
Copy link
Collaborator Author

Plausibly the issue is that nodes are not revealed enough, and we should be revealing nodes before (or after) running rewriting passes

JasonGross added a commit to JasonGross/fiat-crypto that referenced this issue Mar 12, 2025
@JasonGross JasonGross linked a pull request Mar 12, 2025 that will close this issue
JasonGross added a commit to JasonGross/fiat-crypto that referenced this issue Mar 12, 2025
JasonGross added a commit to JasonGross/fiat-crypto that referenced this issue Mar 13, 2025
JasonGross added a commit to JasonGross/fiat-crypto that referenced this issue Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant