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

            Bug ID: 126301
           Summary: Incorrect loop control for loops where latch preceeds
                    loop
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alfierichards at gcc dot gnu.org
  Target Milestone: ---

Created attachment 65074
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65074&action=edit
Graph dump of vect pass output

For AArch64 with partial loops (and riscv I think) when dealing with a loop
such as

> int a;
> char b[];
> int c() {
>   unsigned d = 0;
>   for (; d < a; ++d)
>     if (b[0] + b[d + 1])
>       return 0;
> }

where the loop latch is at the beginning of the loop, the loop control logic
checks if the mask for the "next mask" is not empty, but that is the mask for
the iteration after the one coming.

This is overly pessimistic and guarantees at least a full VF iteration of
scalar fallback code.

https://godbolt.org/z/YGv3M9vEx

Reply via email to