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

            Bug ID: 128665
           Summary: [16/17 Regression] Incorrect predicate on SVE
                    -fno-trapping-math loop
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: aarch64-sve, wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: tnfchris at gcc dot gnu.org
          Reporter: tnfchris at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64*

The following testcase

const double a[] = {0, 1, 2, 3, 4, 5};
__attribute__((noipa))
int f(double x)
{
    int i = 0;
#pragma GCC unroll 0
    while (i < 6 && a[i] <= x)
        ++i;
    return i;
}
int main(void)
{
    int result = f(2.0);
    return result != 3;
}

when compiled with -O3 -fno-trapping-math -march=armv8-a+sve

generates incorrect code:

f:
        ptrue   p15.b, vl16
        ptrue   p7.b, all
        dup     v30.2d, v0.d[0]
        adrp    x2, .LANCHOR0
        add     x1, x2, :lo12:.LANCHOR0
        mov     w0, 0
.L5:
        ldr     q31, [x1]
        add     x1, x1, 16
        fcmle   p14.d, p7/z, z31.d, z30.d
        bics    p14.b, p15/z, p7.b, p14.b
        b.any   .L10
        add     w0, w0, 2
        cmp     w0, 6
        bne     .L5
        ret

The issue is p15.b being created with a byte mask
rather than a .d mask.

Mine.

Reply via email to