Repository: valkey-io/valkey
File: src/hyperloglog.c (C)

Code before:
        raw_ptr += 16;
        dense_ptr += 12;
    }

    /* Process remaining registers, we do this manually because we don't want to over-read 4 bytes */
    uint8_t val;
    for (int i = HLL_REGISTERS - 16; i < HLL_REGISTERS; i++) {
        HLL_DENSE_GET_REGISTER(val, reg_dense, i);
        if (val > reg_raw[i]) {
            reg_raw[i] = val; // Update raw register if new value is greater
        }
    }
}
#endif /* HAVE_ARM_NEON */

/* Merge dense-encoded registers to raw registers array. */
void hllMergeDense(uint8_t *reg_raw, const uint8_t *reg_dense) {
#if HAVE_X86_SIMD
    if (HLL_REGISTERS == 16384 && HLL_BITS == 6) {
        if (HLL_USE_AVX2) {
            hllMergeDenseAVX2(reg_raw, reg_dense);
            return;
        }
    }
#endif
#if __aarch64__ && HAVE_ARM_NEON && HLL_REGISTERS == 16384 && HLL_BITS == 6
    if (HLL_USE_NEON) {
        hllMergeDenseNEON(reg_raw, reg_dense);
        return;
    }
#endif

    uint8_t val;
    for (int i = 0; i < HLL_REGISTERS; i++) {
        HLL_DENSE_GET_REGISTER(val, reg_dense, i);
        if (val > reg_raw[i]) {
            reg_raw[i] = val;
        }
    }
}

/* Merge by computing MAX(registers[i],hll[i]) the HyperLogLog 'hll'
 * with an array of uint8_t HLL_REGISTERS registers pointed by 'max'.
 *
 * The hll object must be already validated via isHLLObjectOrReply()
 * or in some other way.
 *
 * If the HyperLogLog is sparse and is found to be invalid, C_ERR
 * is returned, otherwise the function always succeeds. */
int hllMerge(uint8_t *max, robj *hll) {
    struct hllhdr *hdr = hll->ptr;

Review comment (suggestion):
Build warning/error:

```
hyperloglog.c:1337:5: error: "__aarch64__" is not defined, evaluates to 0 [-Werror=undef]
 1337 | #if __aarch64__ && HAVE_ARM_NEON && HLL_REGISTERS == 16384 && HLL_BITS == 6
      |     ^~~~~~~~~~~
```

We only need to check `HAVE_ARM_NEON`?

```suggestion
#if HAVE_ARM_NEON && HLL_REGISTERS == 16384 && HLL_BITS == 6
```



Code after:
        raw_ptr += 16;
        dense_ptr += 12;
    }

    /* Process remaining registers, we do this manually because we don't want to over-read 4 bytes */
    uint8_t val;
    for (int i = HLL_REGISTERS - 16; i < HLL_REGISTERS; i++) {
        HLL_DENSE_GET_REGISTER(val, reg_dense, i);
        if (val > reg_raw[i]) {
            reg_raw[i] = val; // Update raw register if new value is greater
        }
    }
}
#endif /* HAVE_ARM_NEON */

/* Merge dense-encoded registers to raw registers array. */
void hllMergeDense(uint8_t *reg_raw, const uint8_t *reg_dense) {
#if HAVE_X86_SIMD
    if (HLL_REGISTERS == 16384 && HLL_BITS == 6) {
        if (HLL_USE_AVX2) {
            hllMergeDenseAVX2(reg_raw, reg_dense);
            return;
        }
    }
#endif
#if defined(__aarch64__) && HAVE_ARM_NEON && HLL_REGISTERS == 16384 && HLL_BITS == 6
    if (HLL_USE_NEON) {
        hllMergeDenseNEON(reg_raw, reg_dense);
        return;
    }
#endif

    uint8_t val;
    for (int i = 0; i < HLL_REGISTERS; i++) {
        HLL_DENSE_GET_REGISTER(val, reg_dense, i);
        if (val > reg_raw[i]) {
            reg_raw[i] = val;
        }
    }
}

/* Merge by computing MAX(registers[i],hll[i]) the HyperLogLog 'hll'
 * with an array of uint8_t HLL_REGISTERS registers pointed by 'max'.
 *
 * The hll object must be already validated via isHLLObjectOrReply()
 * or in some other way.
 *
 * If the HyperLogLog is sparse and is found to be invalid, C_ERR
 * is returned, otherwise the function always succeeds. */
int hllMerge(uint8_t *max, robj *hll) {
    struct hllhdr *hdr = hll->ptr;