[all-commits] [llvm/llvm-project] b003c6: [mlir][arith] Match folding of `arith.remf` to `ll...
Felix Schneider via All-commits
all-commits at lists.llvm.org
Tue Jun 25 12:01:40 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b003c60904a78eb62702c613f9e61155bad56798
https://github.com/llvm/llvm-project/commit/b003c60904a78eb62702c613f9e61155bad56798
Author: Felix Schneider <fx.schn at gmail.com>
Date: 2024-06-25 (Tue, 25 Jun 2024)
Changed paths:
M mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
M mlir/lib/Dialect/Arith/IR/ArithOps.cpp
M mlir/test/Dialect/Arith/canonicalize.mlir
Log Message:
-----------
[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 at gmail.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list