https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68235
Bug ID: 68235 Summary: gimple optimisations always use global -fmath-errno setting Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rsandifo at gcc dot gnu.org Target Milestone: --- At the moment the ECF_* flags for a gimple call to a built-in function are derived from the function decl, which in turn is derived from the global command-line options. So if the compiler is run with -fno-math-errno, we always assume functions don't set errno, regardless of local optimisation options. Similarly if the compiler is run with -fmath-errno, we always assume functions set errno. This shows up in gcc.dg/lto/20110201-1_0.c, where we compile the file with -O0 and use -O2 -ffast-math for a specific function. -O2 -ffast-math is enough for us to convert cabs to sqrt as hoped, but because of the global -fmath-errno setting, we assume that the call to sqrt is not pure or const and create vops for it. This makes it appear to the gimple code that a simple sqrt optab isn't enough.