This adds the following two rules when the "no infs" fast-math
flag is set:
fcmp ninf pred (fdiv ninf 1., x), 0 -> fcmp pred x, 0 fcmp ninf pred (fdiv ninf -1., x), 0 -> fcmp swap(pred) x, 0
To justify the first rule:
- All of the following cases show that with or without fdiv the sign is the same and 0 does not occur.
- fdiv 1., small number <-> + large number or +inf on overflow
- fidv 1., -small number <-> - large number or -inf on overflow
- fdiv 1., big number <-> + small normal or denormal number (Example: 1./FLT_MAX = 1./0x0x1.fffffep+127 = 0x1p-128)
- fdiv 1., big number <-> - small normal or denormal number
NaN is preserved:
- fdiv 1., nan <-> nan
- fdiv 1., -nan <-> -nan
The following cases do not work correctly:
- fdiv 1., 0 <-> inf
- fdiv 1., -0 <-> -inf
- fdiv 1., inf </-> 0
- fdiv 1., -inf </-> -0
However having a "no inf" fast-math flag on the fcmp and the fdiv allows
us to ignore these cases.
The 2nd rule can be shown to be a variant of the first:
fcmp pred (fdiv -1., x), 0 -> fcmp pred fneg (fdiv 1., x), 0 -> fcmp swap(pred) (fdiv 1., x), 0 -> fcmp swap(pred) x, 0
Question to reviewers: Is it correct to assume that with fcmp ninf (fdiv 1.0, x) the input to fcmp cannot be +/- infinity and hence x cannot be +/- 0?
Some tests with vectors would be nice