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

Unsigned shift of signed value during optimized signed divide that is only valid because of additional multiplication fails to simplify #4366

Open
D0ntPanic opened this issue May 30, 2023 · 0 comments
Labels
Component: Core Issue needs changes to the core Core: HLIL Issue involves High Level IL Effort: Low Issue should take < 1 week IL Optimization Issue involving optimization of representation (not correctness) Impact: Low Issue is a papercut or has a good, supported workaround Type: Enhancement Issue is a small enhancement to existing functionality

Comments

@D0ntPanic
Copy link
Member

Sometimes the compiler can emit a pattern for optimized modulus where the optimized division component of the modulus
is not valid on its own. It can use an unsigned shift by a small amount during a signed division, which normally would
cause the result to be incorrect, but it can be correct if that result is later multiplied by a value, causing all
values to produce the correct result.

Because Binary Ninja first simplifies the optimized divide, then simplifies the modulus, it cannot simplify the
expression at all.

unsigned_shift

Binary with examples:

unsigned_shift.zip

See 12, 24, 36, 48, and others.

@D0ntPanic D0ntPanic added Component: Core Issue needs changes to the core Core: HLIL Issue involves High Level IL IL Optimization Issue involving optimization of representation (not correctness) Impact: Low Issue is a papercut or has a good, supported workaround Effort: Low Issue should take < 1 week labels May 30, 2023
@xusheng6 xusheng6 added the Type: Enhancement Issue is a small enhancement to existing functionality label Jul 4, 2023
@lwerdna lwerdna added this to the Dorsai milestone Nov 15, 2023
@plafosse plafosse removed this from the Dorsai milestone Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Issue needs changes to the core Core: HLIL Issue involves High Level IL Effort: Low Issue should take < 1 week IL Optimization Issue involving optimization of representation (not correctness) Impact: Low Issue is a papercut or has a good, supported workaround Type: Enhancement Issue is a small enhancement to existing functionality
Projects
None yet
Development

No branches or pull requests

4 participants