https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91425
Bug ID: 91425
Summary: Ordered compares aren't optimised properly
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: segher at gcc dot gnu.org
Target Milestone: ---
Take this example:
===
#include <math.h>
_Bool lt(double a, double b) { return isless(a, b); }
_Bool lo(double a, double b) { return a < b; }
_Bool ll(double a, double b) { return lt(a,b) || lo(a,b); }
_Bool lx(double a, double b) { return lo(a,b) || lt(a,b); }
===
"lt" is an "unordered" comparison, that is, it does not raise an
exception if one (or both) of the inputs is a NaN, i.e. if the
comparison result is "unordered". "lo" is an "ordered" comparison,
which means it does raise an exception if one of the inputs is a
NaN.
Doing both is the same as just doing the ordered comparison and
using the result for both. "ll" should compile to the same as "lx"
does, and that should be the same as what is generated for "lo".
But it is not; not on rs6000 (with my cmpo patches), and not on x86
either: in both cases all three are different. And in fact the
gimple output for all three is different; I think we need to fix
that before making RTL and the targets behave better.