https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119870
Bug ID: 119870
Summary: `(vector8 unsigned) {0,0x80000000}` and `-0.0`
constant formation could be better
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: aarch64
Take:
```
#define vector8 __attribute__((vector_size(8)))
vector8 unsigned native3(void) {
double x = -0.0;
vector8 unsigned t1;
__builtin_memcpy(&t1, &x, sizeof(x));
return t1;
}
```
Currently GCC produces:
```
adrp x0, .LC0
ldr d0, [x0, #:lo12:.LC0]
ret
```
That is a load from the constant pool.
But we should produce:
```
movi d0, #0
fneg d0, d0
ret
```
Note For:
```
double native0(void) {
double x = -0.0;
return x;
}
```
GCC produces:
```
mov x0, -9223372036854775808
fmov d0, x0
ret
```
Which I also think it might be faster to stay in the fp registers and produce:
```
movi d0, #0
fneg d0, d0
ret
```