Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Intrinsics / Windows API

Description

ARM64 alternative implementation

1

_umul128

128-bit unsigned multiplication

Code Block
languagec
#pragma intrinsic(__umulh)

uint64_t _umul128(uint64_t a, uint64_t b, uint64_t *high) {
  *high = __umulh(a, b);
  return a * b;
}
2

UnsignedMultiply128

3

_addcarry_u64

64-bit add with carry returning the carry flag

Code Block
languagec
uint64_t addcarry(uint64_t x, uint64_t y, uint64_t carry_in, uint64_t *sum) {
   *sum =  x + y + (carry_in !=0 ? 1 : 0);
   return ax > UINT32_MAX - by;
}
4

__rdtsc

Processor time stamp - Number of clock cycles since reset

Code Block
languagec
 int64_t processor_cycle_count() {
        const int64_t pmccntr_el0 = (((3 & 1) << 14) |  // op0
                                 ((3 & 7) << 11) |  // op1
                                 ((9 & 15) << 7) |  // crn
                                 ((13 & 15) << 3) | // crm
                                 ((0 & 7) << 0));   // op2
       return _ReadStatusReg (pmccntr_el0);
 }
5

__popcnt and variants

Counts the number of 1 bits (population count) in a 16-, 32-, or 64-bit unsigned integer.

...