https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109829
Bug ID: 109829 Summary: Optimizing __builtin_signbit(x) ? -x : x or abs for FP Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Target Milestone: --- Consider the following 2 functions: __float128 abs1(__float128 x) { return __builtin_fabsf128(x); } __float128 abs2(__float128 x) { return __builtin_signbit(x) ? -x : x; } They should provide the same results, however the codegen is different: abs1(__float128): pand xmm0, XMMWORD PTR .LC0[rip] ret abs2(__float128): movmskps eax, xmm0 test al, 8 je .L4 pxor xmm0, XMMWORD PTR .LC1[rip] .L4: ret Looks like match.pd miss the __builtin_signbit(x) ? -x : x -> __builtin_fabs*(x) pattern. Playground: https://godbolt.org/z/bsxeozGqv