matt-kempster / m2c

A MIPS and PowerPC decompiler.
GNU General Public License v3.0
386 stars 46 forks source link

fold_divmod mwcc mult_hi ordering fix #266

Closed SeekyCt closed 10 months ago

SeekyCt commented 10 months ago

The final if statement of fold_divmod also assumes that right_expr will be the literal, which MWCC doesn't always follow. Currently a MULT_HI extracted from MULT_HI(x, N) >> M would be normalised to fix this, but if original_expr was the MULT_HI then it might not be in order. Fixing this removes a large chunk of the test failures for MWCC.

Afaik all remaining failures for finding MWCC divisions come down to three things, which I don't think I understand the maths well enough to fix: