https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128939
Bug ID: 128939
Summary: Bad vector reduction with truncate for signed
char-signed char
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: aarch64
Created attachment 66253
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66253&action=edit
testcase
The two functions here should produce the same result but currently only the
unsigned case is decent for aarch64.
Fin
Fine produces:
```
ldr d31, [x0]
ldr d30, [x1]
sub v30.8b, v31.8b, v30.8b
uaddlv h31, v30.8b
fmov w0, s31
cmp w0, 0
cset w0, eq
ret
```
While bad produces:
```
ldr d31, [x0]
ldr d30, [x1]
ssubl v30.8h, v31.8b, v30.8b
bic v30.8h, #255, lsl #8
uaddlv s31, v30.8h
fmov w0, s31
cmp w0, 0
cset w0, eq
ret
```
The ssubl/bic/uaddlv could be replaced with the sequence in fine.