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

            Bug ID: 110731
           Summary: [11/12/13/14 Regression] Wrong-code because of
                    wide-int division since r5-424
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

Since r5-424-g807e902eea17f313 (merge of wide-int) we miscompile following
testcase
(noticed it first with _BitInt(119)):

__int128
foo (void)
{
  struct S { __int128 f : 119; } s = { ((__int128) -18014398509481984) << 64 };
  return s.f / 2;
}

int
main ()
{
  if (foo () != (((__int128) -9007199254740992) << 64))
    __builtin_abort ();
}

The result of dividing (-332306998946228968225951765070086143wb - 1) by 2 is
-166153499473114484112975882535043072wb but we return
166153499473114484112975882535043072wb instead (in hex that is
0, 0xffc0000000000000 signed 119 pair divided by 2 resulting in
0, 0x0020000000000000 signed 119 pair rather than
0, 0xffe0000000000000.

Reply via email to