https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113234
Bug ID: 113234 Summary: missing folding to builtin_isunordered if manual nan comparison is used Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: denis.campredon at gmail dot com Target Milestone: --- Compiled with -O1, on x86-64, f1 and f2 should produce the same code than f3 and f4, but f1 and f2 use two comparisons whereas f3 and f4 only use 1. ------------------- bool f1(float i, float j) { return i !=i || j != j; } bool f2(float i, float j) { return i == i && j == j; } bool f3(float i, float j) { return __builtin_isnan(i) || __builtin_isnan(j); } bool f4(float i, float j) { return !__builtin_isnan(i) && !__builtin_isnan(j); } ------------------------------- It seems that gcc does not fold "f != f" to __builtin_isnan, or too late, leading to the missed optimisation.