Note [Rules for floating-point comparisons]
We need different rules for floating-point values because for floats
it is not true that x = x (for NaNs); so we do not want the equal_rule
rule that mkRelOpRule uses.
Note also that, in the case of equality/inequality, we do /not/
want to switch to a case-expression. For example, we do not want
to convert
case (eqFloat# x 3.8#) of
True -> this
False -> that
to
case x of
3.8#::Float# -> this
_ -> that
See #9238. Reason: comparing floating-point values for equality
delicate, and we don't want to implement that delicacy in the code for
case expressions. So we make it an invariant of Core that a case
expression never scrutinises a Float# or Double#.
This transformation is what the litEq rule does;
see Note [The litEq rule: converting equality to case].
So we /refrain/ from using litEq for mkFloatingRelOpRule. References 1
- The litEq rule: converting equality to case GHC.Core.Opt.ConstantFold
Referenced by 7
- Literal alternatives GHC.Core
- Case expression invariants GHC.Core
- GHC.Core.Lint call site
- GHC.Core.Opt.ConstantFold call site
- GHC.HsToCore.Match.Literal call site
- GHC.Parser.PostProcess call site
- GHC.Tc.Utils.TcType call site