`<ranges>`: `_(Add|Mul)_overflow` could be much faster
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.2k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
New functions (added by #3561) _Add_overflow<Int> and _Multiply_overflow<Int> could be much faster when Int is:
-
Standard integer type. MSVC should consider implementing Clang's checked arithmetic builtins (
__builtin_add_overflowand__builtin_mul_overflow). This would vastly improve performance and codegen.
Also tracked by DevCom-10326281. -
Integer-class type. I believe that it is possible to implement those checked operations directly in
_Signed128and_Unsigned128, for example by modifying already existing functions (overflow could be detected during addition/multiplication?).
This requires further investigation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing _Add_overflow<Int> and _Multiply_overflow<Int> for standard integer types, then inspect the existing implementations of _Signed128 and _Unsigned128. Compare the generated code and performance of the current paths with checked arithmetic builtins where applicable; done means faster overflow operations with behavior preserved for both integer categories.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100