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

            Bug ID: 121604
           Summary: [15/16 Regression] Wrong folding of svbrkb intrinsic
                    since r15-5957-g5289540ed58e42
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acoplan at gcc dot gnu.org
  Target Milestone: ---

The following testcase is miscompiled since
r15-5957-g5289540ed58e42ae66255e31f22afe4ca0a6e15e:

$ cat brkb.c
#include <arm_sve.h>
svbool_t foo() {
  return svbrkb_b_m(svpfalse(), svptrue_b8(), svptrue_b8());
}
$ gcc/xgcc -B gcc -c brkb.c -O2 -march=armv8.2-a+sve -S -o -
        .arch armv8.2-a+crc+sve
        .file   "brkb.c"
        .text
        .align  2
        .p2align 5,,15
        .global foo
        .variant_pcs    foo
        .type   foo, %function
foo:
.LFB2:
        .cfi_startproc
        ptrue   p0.b, all
        ret
        .cfi_endproc
.LFE2:
        .size   foo, .-foo
        .ident  "GCC: (GNU) 16.0.0 20250819 (experimental) [master
7eb8b65780d]"
        .section        .note.GNU-stack,"",@progbits

it should instead fold to pfalse, see the definition of the intrinsic here:
https://developer.arm.com/architectures/instruction-sets/intrinsics/svbrkb[_b]_m

For a runtime testcase, take the following:

```
#include <arm_sve.h>

__attribute__((noipa))
svbool_t foo() {
  return svbrkb_b_m(svpfalse(), svptrue_b8(), svptrue_b8());
}

int main(void)
{
  /* brkb (ptrue) -> pfalse.  */
  if (svptest_any (svptrue_b8 (), foo ()))
      __builtin_abort ();
}
```

It looks like BRKA is affected too, at first glance.

Reply via email to