Skip to content

Clang does not recognize portable add-with-carry patterns #73847

@davidben

Description

@davidben

When writing code for cryptographic primitives, or big integers in general, one often needs to use the ISA's add-with-carry instructions and chain carry flags up a bignum.

Although Clang does provide Clang-specific intrinsics like __builtin_addc, they're not portable across compilers. I made several attempts to write a portable add-with-carry here, and Clang seems unable to recognize any of them. Here's a godbolt link with a bunch of them:
https://godbolt.org/z/WTns6M8E6

(CC @andres-erbsen, do you remember if there were other patterns we'd tried?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions