Skip to content

inefficient codegen for absolute value #39

@ZERICO2005

Description

@ZERICO2005

TL:DR emit a libcall for absolute value so we don't clobber a bunch of registers.

The compiler emits this to do an inlined and branchless absolute value:

int mask = (signed)input >> BIT_WIDTH - 1;
int output = (input + mask) ^ mask);

But as we know, XOR is slow, so we should tell the compiler to emit

call __*cmpzero
call m, __*neg

Or possibly a new libcall function dedicated to performing the absolute value

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmissed optimizationMissed optimizations generate correct (no bugs) but not optimal code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions