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:
Denominators generated are exceeding (1 << 29), which blocks the translation of ((x / N) + ((x / N) >> 31)) --> x / N
MWCC also uses inner subtraction in negative divisions
The round_div fails for the MULT_HI constants used in -4 and -7
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:
(1 << 29)
, which blocks the translation of((x / N) + ((x / N) >> 31)) --> x / N
round_div
fails for the MULT_HI constants used in -4 and -7