https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93133
Bug ID: 93133 Summary: __builtin_isgreater emits trapping compare instruction Product: gcc Version: 9.2.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: kretz at kde dot org Target Milestone: --- Target: aarch64-*-* Compile the following test case for aarch64 with -O2: #include <cfenv> int f(float x, float y) { std::feclearexcept(FE_ALL_EXCEPT); int r = -__builtin_isgreater(x, y); if (std::fetestexcept(FE_ALL_EXCEPT) != 0) __builtin_abort(); return r; } int main() { float x = 0.f; return f(x / x, 1.f); } The __builtin_isgreater call is turned into a trapping fcmgt instruction. The negation is necessary to trigger this issue. The same issue seems to exists for all non-trapping compare functions.