> --
> You received this message because you are subscribed to the Google Groups "X86-64 System V Application Binary Interface" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
x86-64-abi+...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/x86-64-abi/877cjd7oea.fsf%40oldenburg.str.redhat.com.
Unspecifying unused bits has more efficient +,-,*,<<, narrowing, and
atomics when supported.
Zeroing unused bits has more efficient comparison and widening.
% cat bit.c
#ifdef B
typedef _BitInt(B) T;
#elif defined(I)
typedef int T;
#else
typedef char T;
#endif
typedef _BitInt(7) T1;
extern T y;
long sextload(T *x) { return *x; }
// Fast if unused bits are zeros
int load_and_cmp(T x) { return x == y; }
unsigned long zextload(T *x) { return *x; }
int less(T x, T y) { return x < y; }
void store(T x) { y = x; }
T rsh(T x, int y) { return x>>y; }
// Fast if unused bits are unspecified
T plus(T x, T y) { return x+y; }
T mul(T x, T y) { return x*y; }
T lsh(T x, int y) { return x<<y; }
T1 narrow(T x) { return x; }
//void atomic_inc(_Atomic T *x) { ++*x; }
---
When storing a _BitInt to a global variable or returning a _BitInt,
can the unused bits be unspecified?
---
https://github.com/llvm/llvm-project/issues/62032 Clang's
implementation currently has a problem that when a loaded _BitInt is
extended, the high bits are not explicitly cleared.