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

            Bug ID: 119869
           Summary: copysign(0, x) code could be better
           Product: gcc
           Version: 15.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:
```
double native1(double x) {
    return __builtin_copysign(0, x);
}
```

Currently GCC produces:
```
        movi    v30.4s, 0
        movi    d31, #0
        fneg    v30.2d, v30.2d
        bif     v0.8b, v31.8b, v30.8b
        ret
```

But the movi/bfi could be merged just into an and.

Like:
```
        movi    d1, #0000000000000000
        fneg    d1, d1
        and     v0.8b, v0.8b, v1.8b
        ret
```

Reply via email to