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

[OpenGOAL] make multiplication/divsion like GOAL and support in decompiler #483

Merged
merged 3 commits into from
May 14, 2021

Conversation

water111
Copy link
Collaborator

@water111 water111 commented May 14, 2021

This makes power-of-two multiplies and divides optimized to shifts work correctly in the compiler/decompiler.

There is a possibility of false detection. The behavior will still be correct, but there might be a multiply/divide when the original code had a shift.

The decompiler uses these rules to pick between shifting and multiply/divide.

  • bitfield access always wins over a multiply or divide. Accessing bitfields will not be affected by this change.
  • Large shifts (over 10, or multiply/divide by 1024) are not converted to multiplication or division.
  • Unsigned divides (logical shift) are never converted to division. Too many false positives and GOAL programmers didn't use uint types very often.

This also adds the same optimization to OpenGOAL and implements unsigned division. Previously it just did signed division every time.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 843605553

  • 121 of 149 (81.21%) changed or added relevant lines in 10 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 69.213%

Changes Missing Coverage Covered Lines Changed/Added Lines %
common/util/BitUtils.h 8 9 88.89%
decompiler/IR2/FormExpressionAnalysis.cpp 36 42 85.71%
decompiler/IR2/bitfields.cpp 17 38 44.74%
Files with Coverage Reduction New Missed Lines %
decompiler/IR2/FormExpressionAnalysis.cpp 1 80.72%
decompiler/IR2/Form.cpp 2 73.99%
Totals Coverage Status
Change from base Build 843069498: 0.01%
Covered Lines: 34469
Relevant Lines: 49801

💛 - Coveralls

@water111 water111 linked an issue May 14, 2021 that may be closed by this pull request
@water111 water111 merged commit d9f9d36 into master May 14, 2021
@water111 water111 deleted the w/shift-mult-div branch May 14, 2021 22:43
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 this pull request may close these issues.

[decompiler] convert shifts to power of two multiplies/divides
2 participants