-
Notifications
You must be signed in to change notification settings - Fork 253
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
Add ((id+/-e)+/-id) simplification rule #1268
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some regressions, which need to be addressed.
binLeft.Left, binExp.Right), | ||
binLeft.Right); | ||
return (binExp, true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a safe transformation when taking unsigned or signed overflow into account? I refer to the regression suite, where several subjects have regressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, (id + e) - id is always e. Given id=0xffffffff , e = 1, (0xffffffff + 1) = 0, (0 - 0xffffffff) = 1. But I need to do more detailed testing on mentioned samples. Maybe there are problems at other rules.
@@ -17161,7 +17161,7 @@ byte fn0000EB48(Eq_n r0, Eq_n r1, ui32 r2, struct Eq_n * r3, Eq_n r4, Eq_n r5, s | |||
if (r2_n <= r5_n) | |||
{ | |||
r2_n.u0 = r5_n.u0 + 1; | |||
if (r5_n.u0 + 1 < r5_n) | |||
if (false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a saturated add: first check for unsigned overflow, and if so, force the value to 0xFFFFFFFF. This regression cannot be allowed.
@@ -193,7 +193,7 @@ int32 fn0000275C(struct Eq_n * a0, struct Eq_n * a5, struct Eq_n & a0Out) | |||
a5->ptrFFFFFAD0 = a0; | |||
struct Eq_n * d0_n = a0; | |||
struct Eq_n * d1_n = (char *) &a0->t0004 + 4; | |||
if (&a0->dw0FF8 > a0) | |||
if (true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also a regression that needs addressing.
It's unsafe to simplify 'cond(e)'. This operation actually requires flags of expression, not expression itseft. So ConditionCodeEliminator should do its work before. For instance we have cond(x - y) where x = y + 1 and can't simplify it to cond((y + 1) - y) => cond(1). 'y + 1 > y' can be used as test for overflow.
55d58e8
to
559c92a
Compare
No description provided.