[Bug tree-optimization/126650] [17 Regression] Wrong code at -O2/3/s on x86_64-pc-linux-gnu

"rguenth at gcc dot gnu.org via Gcc-bugs" <[email protected]> Wed, 05 Aug 2026 08:26:39 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126650

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
So it's

      aff_tree off1, off2;
      poly_widest_int size1, size2;
      get_inner_reference_aff (DR_REF (a), &off1, &size1);
      get_inner_reference_aff (DR_REF (b), &off2, &size2);
      aff_combination_scale (&off1, -1);
      aff_combination_add (&off2, &off1);
      if (aff_comb_cannot_overlap_p (&off2, size1, size2))
        return false;

that triggers for f.e[3] vs. f.bf.c.

(gdb) p debug_aff(&off1)
{
  type = sizetype
  offset = 3
  elements = {
    [0] = &f * 1
  }
}
$17 = void
(gdb) p debug_aff(&off2)
{
  type = sizetype
  offset = 2
  elements = {
    [0] = &f * 1
  }
}

the issue is that we have bitpos == 18 and bitsize == 7 and we do

  aff_combination_const (&tmp, sizetype, bits_to_bytes_round_down (bitpos));
  aff_combination_add (addr, &tmp);  

  *size = bits_to_bytes_round_up (bitsize);

so we round down 18 to a 2 byte offset and bitsize up to 1 byte.  But
we have to round up bitsize + bitpos - rounded-down-bitpos.