-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Bug fix for associative operations #8839
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for opening this PR! Could you please add a test case to test/correctness/rfactor.cpp that triggers this? |
|
Yes, I have added a test. |
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.
Just a couple tidying comments. Please also run clang-format or manually format the code identified by the workflow.
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.
LGTM pending full buildbot results
| table.emplace_back(select(x0 > tmax_0 - y0, tmax_0, y0), zero_0, true); // Saturating add | ||
| table.emplace_back(select(x0 < -y0, y0, tmax_0), zero_0, true); // Saturating add | ||
| table.emplace_back(select(x0 > tmax_0 - y0, tmax_0, x0 + y0), zero_0, true); // Saturating add | ||
| table.emplace_back(select(x0 < -y0, x0 + y0, tmax_0), zero_0, true); // Saturating add |
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 don't understand this condition: x0 < -y0 doesn't make sense to me with unsigned integer types.
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.
In uint8, -y0 == 256 - y0 == (255-y0) + 1, which only overflows when y0 is zero, so let's consider that case first. If y0 == 0, x0 < -y0 is always false, so we return 255. That seems wrong. It's fine when y0 != 0
Maybe it's meant to be x0 < ~y0?
Some of the recognized associative operations for saturating addition return y instead of x + y. This PR fixes that bug.