Skip to content

clang-cl does not support MSVC x86(64) div intrinsics #133182

Open
@davidben

Description

@davidben

MSVC has intrinsics corresponding to the x86 DIV instruction:
https://learn.microsoft.com/en-us/cpp/intrinsics/udiv64?view=msvc-170
https://learn.microsoft.com/en-us/cpp/intrinsics/udiv128?view=msvc-170
https://learn.microsoft.com/en-us/cpp/intrinsics/div64?view=msvc-170
https://learn.microsoft.com/en-us/cpp/intrinsics/div128?view=msvc-170

These operations (well, the unsigned ones) are useful in implementing big integer arithmetic. Sadly, clang-cl does not seem to support them. (I'm having to special-case clang-cl from MSVC in some code right now.)

Even with a clang-cl special case, these are not easily accessible from LLVM without inline asm, from what I can tell, because the x86 instructions trap when the quotient doesn't fit in a single word. A priori, trying to divide, say, uint128_t by uint64_t may give a 128-bit result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:headersHeaders provided by Clang, e.g. for intrinsics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions