https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128513

--- Comment #2 from Zhiyang Chen <jeffchen006 at gmail dot com> ---
One more form, wrong at -O1 since r16-37-g0939abea33c ("combine: Better split
point for (and (not X))"); 14.3 and 15.2 are fine. combine simplifies ((~(x |
1) & M) << 29) >> 29 to (~x & M) & -2 and drops the sign extension from bit 98.

int printf(const char *, ...);
unsigned _BitInt(99) a;
int main(void) {
  _BitInt(99) b = ~(a | 1);
  __int128 r = b;
  printf("%lld\n", (long long)(r >> 64));
  return 0;
}

$ gcc -O0 t.c && ./a.out
-1
$ gcc -O1 t.c && ./a.out
34359738367
Clean with -fsanitize=address,undefined (gcc and clang).

Reply via email to