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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If we wanted to support just INSN_UIDs up to 0x55555554, it could be even just
  lra_insn_recog_data_len = index * 3U / 2 + 1;

Looking around, vec.cc has similar limitation, it uses unsigned rather than int
alloc,
and
...
    /* Grow slower when large.  */
    alloc = (alloc * 3 / 2);

  /* If this is still too small, set it to the right size. */
  if (alloc < desired)
    alloc = desired;
So, my understanding is for vectors up to 0x55555555 elements it will do the
expected thing, for larger it will simply reallocate to the desired exact value
(i.e. as if it was an exact growth rather than the normal exponential one).
Perhaps what we could do in both places use
    alloc = (alloc * (size_t) 3 / 2);
plus the if (alloc < desired) alloc = desired;, such that at least on 64-bit
hosts we'd use an exponential growth even after 0x55555555 a little bit, but on
32-bit hosts we'd keep what we do.  On the lra side then
  lra_insn_recog_data_len = index * (size_t) 3 / 2;
  if (lra_insn_recog_data_len <= index)
    lra_insn_recog_data_len = index + 1;

Reply via email to