Canonicalize commutative operations before simplification - #726
Draft
twizmwazin wants to merge 1 commit into
Draft
Canonicalize commutative operations before simplification#726twizmwazin wants to merge 1 commit into
twizmwazin wants to merge 1 commit into
Conversation
Sort the arguments of commutative operations by hash in simplify() so that expressions that differ only in operand order (e.g. x + y and y + x, or And(a, b) and And(b, a)) canonicalize to the same AST. This improves expression sharing and simplification hit rates. Ported from the feat/better-canonicalization branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
twizmwazin
marked this pull request as draft
June 6, 2026 00:52
Member
|
Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/claripy_726 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sorts the arguments of commutative operations by hash in
simplify()so that expressions differing only in operand order canonicalize to the same AST:x + yandy + xproduce the same expressionAnd(a, b)andAnd(b, a)produce the same expressionThis improves expression sharing and simplification hit rates. Ported from the
feat/better-canonicalizationbranch (just the commutative-canonicalization change — independent of #725).Change
plus the
from claripy import operationsimport.Testing
Verified canonicalization behavior locally (
x + y is y + x,And(x==1, y==2) is And(y==2, x==1)). Running the full angr test suite against this branch is in progress; will follow up with results.🤖 Generated with Claude Code