Files
clang-p2996/mlir/test/Dialect/Arith
Felix Schneider b003c60904 [mlir][arith] Match folding of arith.remf to llvm.frem semantics (#96537)
There are multiple ways to define a remainder operation. Depending on
the definition, the result could be either always positive or have the
sign of the dividend.
The pattern lowering `arith.remf` to LLVM assumes that the semantics
match `llvm.frem`, which seems to be reasonable. The folder, however, is
implemented via `APFloat::remainder()` which has different semantics.

This patch matches the folding behaviour to lowering behavior by using
`APFloat::mod()`, which matches the behavior of `llvm.frem` and libm's
`fmod()`. It also updates the documentation of `arith.remf` to explain
this behavior: The sign of the result of the remainder operation always
matches the sign of the dividend (LHS operand).

frem documentation: https://llvm.org/docs/LangRef.html#frem-instruction

Fix https://github.com/llvm/llvm-project/issues/94431

---------

Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
2024-06-25 21:01:18 +02:00
..