Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Proposal to add integer abs() #176

Closed
jan-wassenberg opened this issue Jan 14, 2020 · 3 comments
Closed

Proposal to add integer abs() #176

jan-wassenberg opened this issue Jan 14, 2020 · 3 comments

Comments

@jan-wassenberg
Copy link

abs() for integers would be helpful for JPEG XL - we predict pixels from their neighbours and compute the absolute error.

On x86 and ARM, INT32_MIN etc. are unchanged - negating them leads to the same result.

Without this operation, I think we could do u32x4_min(x, neg(x)), where neg(x) is either ~x + 1 or _mm_sign_epi32(x, something_negative), or whatever wasm_i32x4_neg uses, so about 3 instructions. By contrast, abs() can be a single instruction on x86 (_mm_abs_epi8..32) and ARM (vabsq_s8..32).

Has this been considered/discussed already?

@Maratyszcza
Copy link
Contributor

There is PR #128 that propose integer absolute value instructions.

@jan-wassenberg
Copy link
Author

Oh, nice! Sorry about the duplication, I only checked for other issues, not PRs.

@dtig
Copy link
Member

dtig commented Feb 18, 2020

Closing as duplicate of #128 which is now merged.

@dtig dtig closed this as completed Feb 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants