[Bug tree-optimization/126595] [13/14/15/16/17 Regression] Wrong code with loop distribution on SVE and compute_alias_check_pairs

"rguenth at gcc dot gnu.org via Gcc-bugs" <[email protected]> Mon, 03 Aug 2026 12:31:12 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D126595

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-08-03
      Known to work|                            |7.5.0
   Target Milestone|---                         |13.5
                 CC|                            |rsandifo at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
             Target|aarch64                     |aarch64, x86_64-*-*
            Summary|Wrong code with loop        |[13/14/15/16/17 Regression]
                   |distribution on SVE and     |Wrong code with loop
                   |compute_alias_check_pairs   |distribution on SVE and
                   |                            |compute_alias_check_pairs
      Known to fail|                            |13.4.0, 17.0, 8.4.0
           Priority|P3                          |P2

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Also aborts on x86_64 with -fno-tree-vectorize or with -O2
-ftree-loop-distribution -fno-tree-vectorize

t.c:6:21: optimized: Loop 1 distributed: split to 2 loops and 0 library cal=
ls.
t.c:6:21: optimized: loop unrolled 1 times
t.c:6:21: optimized: Loop 1 distributed: split to 2 loops and 0 library cal=
ls.
t.c:6:21: optimized: loop unrolled 1 times
t.c:26:21: optimized: Loop 1 distributed: split to 0 loops and 1 library ca=
lls.
t.c:28:21: optimized: loop unrolled 1 times

Full dump:

Version loop <1> with runtime alias check
Creating alias check pairs:
merging ranges for *_9, *_7 and *_12, *_7
merged alias checks:
  reference:      *_4 vs. *_12
  segment length: (sizetype) ((unsigned int) n_18(D) + 4294967295) * 4
  access size:    4
  alignment:      4
  flags:          WAR ARBITRARY
  reference:      *_7 vs. *_9
  segment length: ((sizetype) ((unsigned int) n_18(D) + 4294967295) +
18446744073709551615) * 4 vs. (sizetype) ((unsigned int) n_18(D) + 42949672=
95)
* 4
  access size:    4 vs. 8
  alignment:      4
  flags:          RAW WAW ARBITRARY
Improved number of alias checks from 3 to 2


I think

          /* The new check will start at DR_A1.  Make sure that its access
             size encompasses the initial DR_A2.  */
          if (maybe_lt (dr_a1->access_size, diff + dr_a2->access_size))
            {
              dr_a1->access_size =3D upper_bound (dr_a1->access_size,
                                                diff + dr_a2->access_size);
              unsigned int new_align =3D known_alignment (dr_a1->access_siz=
e);
              dr_a1->align =3D MIN (dr_a1->align, new_align);
            }

doesn't work and I wonder why we not adjust the segment length for the offs=
et
case?  Richard?=