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

Fails to identify simple MBA and to optimize code #3

Closed
pgarba opened this issue Jan 26, 2023 · 2 comments
Closed

Fails to identify simple MBA and to optimize code #3

pgarba opened this issue Jan 26, 2023 · 2 comments

Comments

@pgarba
Copy link

pgarba commented Jan 26, 2023

Hi,

I tested goomba on a simple program and it seems to fail to detect MBAs within a compare and return.

MBA: 2 * (a2 & a1) + (a2 ^ a1) , (a1 + a2)

Before:

__int64 __fastcall test(int a1, int a2) 
{
  if ( a2 + a1 == 2 * (a2 & a1) + (a2 ^ a1) )
    return (2 * (a2 & a1) + (a2 ^ a1));
  else
    return (3 * (2 * (a2 & a1) + (a2 ^ a1)));
}

After goomba:

__int64 __fastcall test(int a1, int a2)
{
  if ( a2 + a1 == 2 * (a2 & a1) + (a2 ^ a1) ) // Failed to detect MBA here
    return (2 * (a2 & a1) + (a2 ^ a1));   // Failed to detect this MBA
  else
    return (3 * a2 + 3 * a1); // This MBA got simplified
}

Expected result after goomba:

__int64 __fastcall test(int a1, int a2)
{
  if ( a2 + a1 == a2 + a1 )
    return (a1 + a2)
  else
    return (3 * (a1 + a2)); 
}

@pgarba pgarba changed the title Fails to identify MBA in compare Fails to identify simple MBA and to optimize code Jan 26, 2023
@0xeb
Copy link

0xeb commented Jan 27, 2023

Do you think you can attach a sample binary so the author can test with?

@pgarba
Copy link
Author

pgarba commented Jan 27, 2023

https://github.com/pgarba/Saturn_Results/blob/master/op1/op1.exe

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

No branches or pull requests

2 participants