https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126689
Bug ID: 126689
Summary: Missed removal of nested copysigns
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: easyhack
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ktkachov at gcc dot gnu.org
Target Milestone: ---
double f1 (double x, double y, double z)
{
return __builtin_copysign (x, __builtin_copysign (y, z));
}
float f2 (float x, float y, float z)
{
return __builtin_copysignf (x, __builtin_copysignf (y, z));
}
On aarch64 generates:
f1:
movi v31.4s, 0
fneg v31.2d, v31.2d
bit v1.8b, v2.8b, v31.8b
bit v0.8b, v1.8b, v31.8b
ret
f2:
movi v31.4s, 0x80, lsl 24
bit v1.8b, v2.8b, v31.8b
bit v0.8b, v1.8b, v31.8b
ret
but should do like Clang:
f1:
movi v1.2d, #0xffffffffffffffff
fneg v1.2d, v1.2d
bif v0.16b, v2.16b, v1.16b
ret
f2:
mvni v1.4s, #128, lsl #24
bif v0.16b, v2.16b, v1.16b
ret