Fold arith.fadd %x, -0.0 -> %x and similarly for fsub, fmul, fdiv.
Fold arith.fmin %x, %x -> %x, arith.fmin %x, +inf -> %x and similarly for fmax.
Paths
| Differential D118244
[MLIR][arith] More float op folders ClosedPublic Authored by csigg on Jan 26 2022, 6:27 AM.
Details Summary Fold arith.fadd %x, -0.0 -> %x and similarly for fsub, fmul, fdiv. Fold arith.fmin %x, %x -> %x, arith.fmin %x, +inf -> %x and similarly for fmax.
Diff Detail
Event Timelinebondhugula added inline comments.
Comment Actions Adding float value matchers and using the same pattern for int value matchers for consistency. csigg added inline comments.
Comment Actions @jpienaar mentioned to me that `add %x
Comment Actions Can you add context and motivation in the description also? "Remove 'Commutative' interface from fmin/fmax " deserve to be explained, I would even say that it deserve a separate revision from adding folders on simple arithmetic. Comment Actions Addressing reviewer comments:
Comment Actions
I would even say that it deserve a separate revision from adding folders on simple arithmetic. Split out into https://reviews.llvm.org/D118318.
This revision is now accepted and ready to land.Jan 28 2022, 3:31 AM csigg retitled this revision from More arith float op folders to [MLIR][arith] More float op folders.Jan 31 2022, 5:10 AM Closed by commit rGf278cf9cbc3e: [MLIR][arith] More float op folders (authored by csigg). · Explain WhyJan 31 2022, 10:31 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 404483 mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td
mlir/include/mlir/IR/Matchers.h
mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp
mlir/test/Dialect/Arithmetic/canonicalize.mlir
mlir/test/Dialect/Linalg/vectorization.mlir
mlir/test/Dialect/SCF/loop-pipelining.mlir
|
Actually I think that %x + 0.0 can't be folded to %x, but %x + -0.0 can!
That's because -0. + 0. == +0.0.
Seems very relevant to https://llvm.discourse.group/t/rfc-fastmath-flags-support-in-mlir-arith-dialect/6049/2