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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|incorrect results using     |[8/9/10/11 Regression]
                   |__uint128_t                 |incorrect results using
                   |                            |__uint128_t
                 CC|                            |jakub at gcc dot gnu.org
          Component|c++                         |tree-optimization
   Target Milestone|---                         |8.5

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r5-424-g807e902eea17f3132488c256c963823976b2348c
C testcase that just needs -O2:
__attribute__ ((noipa)) void
foo (__uint128_t *x)
{
  asm volatile ("" : : "r" (x) : "memory");
}

int
main ()
{
  __uint128_t a = ((__uint128_t) 1) << 65;
  __uint128_t b = a;
  __uint128_t n;
  foo (&b);
  n = b;
  while (n >= a)
    n -= a;
  if ((int) (n >> 64) != 0)
    __builtin_abort ();
  return 0;
}

Works fine with unsigned long long instead of __uint128_t and 33 instead of 65
and 32 instead of 64, so either a wide-int bug or number of loop iterations
bug.
On the ullong testcase, e.g. profile_estimate prints:
Analyzing # of iterations of loop 1
  exit condition 8589934591 < [n_8, + , 18446744065119617024]
  bounds on difference of bases: -8589934591 ... 18446744065119617024
  result:
    # of iterations n_8 / 8589934592, bounded by 2147483647
but on the uint128_t testcase it prints:
Analyzing # of iterations of loop 1
  exit condition 0x1ffffffffffffffff < [n_8, + ,
0xfffffffffffffffe0000000000000000]
  bounds on difference of bases: -36893488147419103231 ...
-18446744073709551616
  result:
    # of iterations n_8 / 0x20000000000000000, bounded by 0

Reply via email to