https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119187
--- Comment #16 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Friday vectorizer codegen fun.
```
#include <arm_neon.h>
#include <arm_sve.h>
void foo (uint8_t *a, uint8_t *b, uint8_t *c, int n)
{
for (int i = 0; i < n; i+=8, a+=8, b+=8, c+=8)
{
uint8x8_t av1 = vld1_u8 (a);
uint8x8_t bv1 = vld1_u8 (b);
uint8x8_t cmp = vcgt_u8 (bv1, vdup_n_u8 (0));
uint8x8_t add = vadd_u8 (bv1, vdup_n_u8 (1));
uint8x8_t sel = vbsl_u8 (cmp, add, bv1);
vst1_u8 (a, sel);
}
}
```
now when compiled with `-O3 -march=armv9-a` instead of
```
.L3:
ldr d28, [x1, x2]
cmtst v27.8b, v28.8b, v28.8b
add v26.8b, v28.8b, v29.8b
bif v26.8b, v28.8b, v27.8b
str d26, [x0, x2]
add x2, x2, 8
cmp w3, w2
bgt .L3
```
generates
``` mov z30.b, #1
.L4:
ld1b z31.b, p7/z, [x1, x2]
cmpne p6.b, p7/z, z31.b, #0
add z31.b, p6/m, z31.b, z30.b
st1b z31.b, p7, [x0, x2]
incb x2
whilelo p7.b, x2, x3
b.any .L4```
with the vectorizer reporting
```
note: ------>vectorizing SLP node starting from: _14 =
__builtin_aarch64_simd_bslv8qi_uuuu (_11, _13, _10);
note: vect_is_simple_use: operand patt_22 ? -1 : 0, type of def: internal
note: vect_is_simple_use: operand _10 + { 1, 1, 1, 1, 1, 1, 1, 1 }, type of
def: internal
note: vect_is_simple_use: operand # VUSE <.MEM_26>
MEM <__Uint8x8_tD.2485> [(unsigned charD.21 * {ref-all})b_24], type of def:
internal
note: transform vector call.
note: add new stmt: vect_vect_patt_21.19_63 =
VIEW_CONVERT_EXPR<svuint8_t>(vect_patt_21.16_60);
note: inserted type shim between: svuint8_t and vector([16,16]) unsigned
char due to mismatch between generic type and vector call.
note: add new stmt: vect_vect__13.20_64 =
VIEW_CONVERT_EXPR<svuint8_t>(vect__13.17_61);
note: inserted type shim between: svuint8_t and vector([16,16]) unsigned
char due to mismatch between generic type and vector call.
note: add new stmt: vect_vect__10.21_65 =
VIEW_CONVERT_EXPR<svuint8_t>(vect__10.14_58);
note: inserted type shim between: svuint8_t and vector([16,16]) unsigned
char due to mismatch between generic type and vector call.
note: add new stmt: vect__14.22_66 = svbsl_u8 (vect_vect_patt_21.19_63,
vect_vect__13.20_64, vect_vect__10.21_65);
note: add new stmt: vect__14.18_62 = VIEW_CONVERT_EXPR<vector([16,16])
unsigned char>(vect__14.22_66);
note: inserted type shim between: svuint8_t and vector([16,16]) unsigned
char due to mismatch between generic type and vector call.
```
and at -O3 -march=armv8-a
```
.L4:
ldr q30, [x1, x2]
cmtst v29.16b, v30.16b, v30.16b
add v28.16b, v30.16b, v31.16b
bif v28.16b, v30.16b, v29.16b
str q28, [x0, x2]
add x2, x2, 16
cmp x2, x5
bne .L4
cmp w4, w7, lsl 4
beq .L1
lsl x4, x6, 7
movi v25.8b, 0x1
lsl w2, w7, 7
add x6, x1, x4
add w7, w2, 8
add x5, x0, x4
ldr d31, [x1, x4]
cmtst v30.8b, v31.8b, v31.8b
add v29.8b, v31.8b, v25.8b
bif v29.8b, v31.8b, v30.8b
str d29, [x0, x4]
cmp w3, w7
ble .L1
```
with
```
note: ------>vectorizing SLP node starting from: _14 =
__builtin_aarch64_simd_bslv8qi_uuuu (_11, _13, _10);
note: vect_is_simple_use: operand patt_22 ? -1 : 0, type of def: internal
note: vect_is_simple_use: operand _10 + { 1, 1, 1, 1, 1, 1, 1, 1 }, type of
def: internal
note: vect_is_simple_use: operand # VUSE <.MEM_26>
MEM <__Uint8x8_tD.2485> [(unsigned charD.21 * {ref-all})b_24], type of def:
internal
note: transform vector call.
note: add new stmt: vect_vect_patt_21.23_90 =
VIEW_CONVERT_EXPR<__Uint8x16_t>(vect_patt_21.20_87);
note: inserted type shim between: __Uint8x16_t and vector(16) unsigned char
due to mismatch between generic type and vector call.
note: add new stmt: vect_vect__13.24_91 =
VIEW_CONVERT_EXPR<__Uint8x16_t>(vect__13.21_88);
note: inserted type shim between: __Uint8x16_t and vector(16) unsigned char
due to mismatch between generic type and vector call.
note: add new stmt: vect_vect__10.25_92 =
VIEW_CONVERT_EXPR<__Uint8x16_t>(vect__10.18_85);
note: inserted type shim between: __Uint8x16_t and vector(16) unsigned char
due to mismatch between generic type and vector call.
note: add new stmt: vect__14.26_93 = __builtin_aarch64_simd_bslv16qi_uuuu
(vect_vect_patt_21.23_90, vect_vect__13.24_91, vect_vect__10.25_92);
note: add new stmt: vect__14.22_89 = VIEW_CONVERT_EXPR<vector(16) unsigned
char>(vect__14.26_93);
note: inserted type shim between: __Uint8x16_t and vector(16) unsigned char
due to mismatch between generic type and vector call.
```
Things left before I send an RFC:
* vector patterns
* reductions (including accum splits)
* inductions
* unpacking (matching _hi/_lo)
* permutes
* alias analysis
* if-convert