Skip to content

Bug in __GNUC__ optimization for popcnt(x) #1

@testuser220

Description

@testuser220

Hello,

In file "integer.h", in this section:

#if defined I128_USE_BITS
#include "bits.h"
#elif defined GNUC
#define clz(x) extension ({ uint n = __builtin_clzll(x); n == 0 ? 64 : n; })
#define ctz(x) extension ({ uint n = __builtin_ctzll(x); n == 0 ? 64 : n; })
#define popcnt(x) __builtin_popcount(x)
#define bswap64(x) __builtin_bswap64(x)
#elif defined _MSC_VER
#include <intrin.h>
#define clz(x) _lzcnt_u64(x)
#define ctz(x) _tzcnt_u64(x)
#define popcnt(x) __popcnt64(x)
#define bswap64(x) _byteswap_uint64(x)
#endif

I think the GNUC version for popcnt(x) shall be 64-bit, not 32-bit (with -ll suffix)?

#define popcnt(x) __builtin_popcountll(x)

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions