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 403242 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
|
I think this won't work for non f32 Values. You need to create an APFloat zero with the right float semantics. All your test cases are with f32 -- could you add/try one with f16 or f64?