https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85950
Bug ID: 85950 Summary: Unsafe-math-optimizations regresses optimization using SSE4.1 roundss Product: gcc Version: 8.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: linux at carewolf dot com Target Milestone: --- When SSE4.1 is available, std::floor, std::ceil and their C counterparts are inlined to being a single roundss instruction. However if compiled with -Ofast, -ffast-math or -funsafe-math-optimization specifically, then you instead get a slightly improved version of the much slower SSE2 implementation of the same functions. For instance compiling this with -msse4.1: #include <cmath> double stdfloor(double a) { return std::floor(a); } double stdceil(double a) { return std::ceil(a); }