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

Proposal to add integer abs() #176

Closed
@jan-wassenberg

Description

@jan-wassenberg

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions