Issue 237547
Summary Neon-sve conversions for bool registers are not optimized
Labels new issue
Assignees
Reporter DenisYaroshevskiy
    Converting an SVE predicate to a NEON mask and back with the ACLE NEON-SVE bridge should just trim the predicate to its low 128 bits. Instead the conversion instructions are kept.

```
inline uint8x16_t sve2neon(svbool_t p)   { return svget_neonq(svdup_u8_z(p, 0xFF)); }
inline svbool_t   neon2sve(uint8x16_t m) { return svcmpne(svptrue_pat_b8(SV_VL16), svset_neonq(svundef_u8(), m), 0); }

svbool_t roundtrip(svbool_t p) { return neon2sve(sve2neon(p)); }
svbool_t expected(svbool_t p)  { return svand_z(svptrue_pat_b8(SV_VL16), p, p); }
```

Asm
```
roundtrip(__SVBool_t):
        mov     z0.b, p0/z, #-1
        ptrue   p0.b, vl16
        cmpne   p0.b, p0/z, z0.b, #0
 ret

expected(__SVBool_t):
        ptrue   p1.b, vl16
        and p0.b, p1/z, p1.b, p0.b
        ret
```
Godbolt: https://godbolt.org/z/KcTc6G5av

Same is true for other element sizes, doesn't matter if it's u8.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to