This is an archive of the discontinued LLVM Phabricator instance.

[mlir][arith] Add pass to globally set fastmath attributes for a module
AcceptedPublic

Authored by jfurtek on Oct 31 2022, 2:49 PM.

Details

Summary

This diff adds a pass to the arith dialect that will set the fastmath
attribute for all operations that support the ArithFastMathInterface
interface. This can be useful to apply module-level fastmath settings in a way
that is similar to setting LLVM fastmath values for an entire file.

Future pass modifications may include adding an option to perform a bitwise
operation on the fastmath flags, to (for example) combine the pass argument with
an existing fastmath value with a bitwise or.

Diff Detail

Event Timeline

jfurtek created this revision.Oct 31 2022, 2:49 PM
jfurtek requested review of this revision.Oct 31 2022, 2:49 PM
tblah added a subscriber: tblah.Nov 3 2022, 4:06 AM
tblah added inline comments.Nov 3 2022, 4:16 AM
mlir/lib/Dialect/Arith/Transforms/SetFastMath.cpp
2

nit: "Wide integer operation emulation" - copy+paste error?

jfurtek updated this revision to Diff 473273.Nov 4 2022, 9:57 AM
  • Fix cut-and-paste error in comment
jfurtek marked an inline comment as done.Nov 4 2022, 9:57 AM
jfurtek added inline comments.
mlir/lib/Dialect/Arith/Transforms/SetFastMath.cpp
2

Fixed - thank you.

vzakhari accepted this revision.Nov 15 2022, 10:07 AM
vzakhari added a subscriber: vzakhari.

LGTM

mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
25

Just FYI, there is bitEnumContainsAll auto-generated overload for FastMathFlags in ArithOpsEnums.h.inc:

inline constexpr bool bitEnumContainsAll(FastMathFlags bits, FastMathFlags bit) {
  return (bits & bit) == bit;
}
mlir/lib/Dialect/Arith/Transforms/SetFastMath.cpp
48

nit: redundant braces

This revision is now accepted and ready to land.Nov 15 2022, 10:07 AM
jfurtek updated this revision to Diff 479509.Dec 1 2022, 7:33 PM
jfurtek marked an inline comment as done.
  • Fix cut-and-paste error in comment
  • Rebase. Use tblgen-erated bit enum function. Remove unnecessary braces.
jfurtek marked 2 inline comments as done.Dec 1 2022, 7:34 PM

Addressed comments. Thank you @vzakhari .

vzakhari accepted this revision.Dec 1 2022, 8:38 PM