diff options
author | Felix Schneider <fx.schn@gmail.com> | 2024-06-25 21:01:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-25 21:01:18 +0200 |
commit | b003c60904a78eb62702c613f9e61155bad56798 (patch) | |
tree | fc503fd32ac0a831efa5c3bc26e2ac8899145328 /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | aec735cf476c3975b026aa79fa40dda06a27fac3 (diff) | |
download | llvm-b003c60904a78eb62702c613f9e61155bad56798.zip llvm-b003c60904a78eb62702c613f9e61155bad56798.tar.gz llvm-b003c60904a78eb62702c613f9e61155bad56798.tar.bz2 |
[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>
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions