-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
[ARMv6] vcvt instruction makes very un-human readable code #7890
Comments
I admit, it's a bit ugly, but it's still readable. vcvt converts a signed integer to a floating point value. So it is calculating a percentage, as you figured. |
Part of the issue is that we don't have a good default value for
|
The variable is a constant of 0 that doesn't get written to anywhere else, but the decompiler never optimizes the bitshifts out and just immediately gives the actual number? That feels weird |
That didn't seem to fix it, did I not add it in correctly, or otherwise not clear it? I highlighted the entire function, pressed C, then D |
You added it correctly. I'm not sure why it is not showing up correctly for you, I'll try to play around with it more |
Are you testing this on the latest commit, or in a release build? Was anything done to improve decompilation of bitshifts since the latest release? It's possible that it was already fixed and I just don't have the fix yet. |
I am testing with the latest build, although I don't believe that should have any impact on it. It's most likely because of the environment. I've taken those bytes in isolation without any surrounding code and placed them in a dummy function in an empty binary I created. The fact that the ghidra is assigning |
i'm looking at other uses of vcvct, and in some cases it's just directly a 0 (when the vcvt happens early on in the function), so i think you're right about some other instruction messing with it. A pattern I'm noticing is that every function that assigns fpscr to a variable has a |
Never mind, found a function with a vpush that doesn't mess up the vcvt. Huh |
found a short enough function with a broken vcvt decompilation
all the vcvts here end up assigning fpscr to a variable. some other functions of similar length don't though, and i'm not really seeing a pattern of what breaks it |
In that case it's because it can't be sure it wasn't modified in a called function. It's probably not possible to completely eliminate the shifts, but in general this is why we prefer to use dummy registers for flags and manually pack/unpack the flags in the status register before it is read or after it's written. We do that with the main flags in ARM32, but not with the floating point status register. |
Probably related to #7377 , or the issue I can't find that had to do with multiple registers being used to store one value that is larger than a single register (an 8 byte length double when registers only hold 4 bytes)
Whenever I'm looking at some code that uses any variation of vcvt (e.g. vcvt.f32.s32), the decompiler ends up spitting out some nonsense involving bitshifts and "VectorSignedToFloat", and it's quite difficult to tell what is actually going on.
It would be nice if the decompiler... didn't do that, and instead did something more... understandable.
I've got 0 clue what this code here is doing, for example, beyond doing Something to calculate a percentage to display? (For context, fVar15 is a Constant that contains 100.0) in_fpscr isn't even a "real variable", it exists solely in vcvt calls and is probably some artifact of the decompiler.
The text was updated successfully, but these errors were encountered: