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

--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Here's an equivalent test case which also exhibits the same behavior:

#include <stdint.h>
#include <string.h>

#define GRPSZ     6
#define TABSZ     729
#define N_GRP     6
#define HALFSIZE  (N_GRP * GRPSZ)

extern const unsigned char tab[TABSZ][GRPSZ];

void foo(unsigned long from_small, unsigned long to_small,
         unsigned char *restrict from_buf, unsigned char *restrict to_buf)
{
    const unsigned long tabszu = TABSZ;

    for (int i = 0; i < HALFSIZE; i += GRPSZ)
      {
        unsigned long to_rem, from_rem;
        to_rem = to_small % tabszu;
        to_small /= tabszu;

        from_rem = from_small % tabszu;
        from_small /= tabszu;

        for (int j=0; j<GRPSZ; j++)
          to_buf[i+j] = tab[to_rem][j];

        for (int j=0; j<GRPSZ; j++)
          from_buf[i+j] = tab[from_rem][j];
      }
}

Reply via email to