[PATCH] D147866: ValueTracking: Implement computeKnownFPClass for minnum/maxnum

Joshua Cranmer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 19 14:27:07 PDT 2023


jcranmer-intel added a comment.

The semantics in the LangRef say:

> If the operands compare equal, returns a value that compares equal to both operands. This means that fmin(+/-0.0, +/-0.0) could return either -0.0 or 0.0.

This is distinctly weaker semantics than IEEE 754-2008's `minNum`. C2x depends on IEEE 754-2019 (which drops `minNum`), but interestingly, neither C11 nor C17 actually try to relate `fmin` to IEEE 754 `minNum`. `minNum` is clearly required to return one of its input arguments.

C is somewhat unclear on the subject, but C2x does mention that `fmin` differs from `fminimum` "in which signed zero is returned when the arguments are differently signed zeros", which would suggest that `fmin(-0, -0)` is `-0` and `fmin(+0, +0)` is `+0`. In other words, the most reasonable interpretation of C is that `fmin` (like `minNum`) returns one of its arguments.

I suspect the wording in the LangRef doesn't match the actual intended semantics. If the operands compare equal, it should return "either value" instead of "a value that compares equal to both operands".


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147866/new/

https://reviews.llvm.org/D147866



More information about the llvm-commits mailing list