- addf(x,0) -> x
- subf(x,0) -> x
- subf(x,x) -> 0
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/StandardOps/IR/Ops.cpp | ||
---|---|---|
299 | Please avoid hardcoding the constant op(hardcoding limits composability), as well as using getZeroAttr(getZeroAttr creates an attribute, which involves uniquing and thus acquiring a lock). operands contains attributes for operands of this operation that are constant, use that instead: if (FloatAttr rhs = operands[1].dyn_cast_or_null<FloatAttr>()) if (rhs.getValue().isZero()) return op.lhs(); |
mlir/lib/Dialect/StandardOps/IR/Ops.cpp | ||
---|---|---|
299 | I was trying to address vector cases. If this limits composability, let's go with your suggestion. |
mlir/lib/Dialect/StandardOps/IR/Ops.cpp | ||
---|---|---|
2766 | Is this valid even when x is NaN or Infinity? |
mlir/lib/Dialect/StandardOps/IR/Ops.cpp | ||
---|---|---|
2766 | I'm not so familiar with floating point here. In LLVM, this is true when fast-math flag is on. It is always valid from the perspective of Math, but not LLVM IR floating-point operations. After revisiting some sections in LLVM doc, I also found that other folders in this patch are might not valid.
https://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics I think the question would be, do we map subf/addf to LLVM intrinsics or math operations? I also noticed that there is a TODO in the doc of addf
In this context, it seems that we follow LLVM intrinsics, and this is only valid if we have fast math attribute (which is set to true)? |
mlir/lib/Dialect/StandardOps/IR/Ops.cpp | ||
---|---|---|
2766 | By "LLVM intrinsics" you mean "LLVM instructions" here I think? (intrinsics and instructions are different classes in LLVM)? Unfortunately floating point isn't just arbitrary math and we're limited here. |
mlir/lib/Dialect/StandardOps/IR/Ops.cpp | ||
---|---|---|
2766 | Yes, I meant LLVM instructions. Got you, thanks! |
Please avoid hardcoding the constant op(hardcoding limits composability), as well as using getZeroAttr(getZeroAttr creates an attribute, which involves uniquing and thus acquiring a lock). operands contains attributes for operands of this operation that are constant, use that instead: