-
Notifications
You must be signed in to change notification settings - Fork 18k
image/png: use branch-free abs function in abs8 #63492
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
Comments
Change https://go.dev/cl/534375 mentions this issue: |
The fix is a few lines, so I created the CL. |
if you've tested and compared the output of your function to the old one you'll see that your "optimized" function doesn't even do the same thing on values >= 129 |
Given the above, the best optimization I could come up with based on a 2's complement approach was the following. Benchmark result differences weren't statistically significant compared to the branching version, so I think we should leave as-is?
|
You are right. My first CL is wrong. It was embarrassing that I ignored the following code comment because all test passed...
|
nakulbajaj's suggestion seems to work. And,
Yes, I agree that. The differences include even worse cases.
|
Thanks for your confirmation! |
This is not a bug issue, but propose of optimization.
So, I change subjects of pr-templates.
overview
In the past CL, a branch-free abs was applied to optimize Paeth filters.
https://codereview.appspot.com/117290043
Applying this to abs8 in write.go also improved the latency of BenchmarkEncodeRGBA by 38%.
result
The text was updated successfully, but these errors were encountered: