Skip to content

<xutility>: Use addition and multiplication overflow check MSVC intrinsics like _add_overflow_i8, _mul_overflow_i16, and _mul_full_overflow_i8 #4780

@AlexGuteniev

Description

@AlexGuteniev

Inspired by #4776

There are Clang intrinsics used in _Mul_overflow and _Add_overflow

MSVC has its own _mul_full_overflow_u8 and others.
Using them would certainly result in a better codegen than the generic implementation.

Caveats:

  • Only for x86 / x64, some are only for x64
  • Not a complete set of all operations possible
  • Not constexpr, unlike the Clang one
  • Need to include <intrin.h>

These might warrant the need of another internal header for _Mul_overflow and _Add_overflow, used by <ranges>, <mdspan>, and <numeric> after #4776.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceMust go fasterwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions