This is an archive of the discontinued LLVM Phabricator instance.

[mlir][arith] Allow to specify `constFoldBinaryOp` result type
ClosedPublic

Authored by kuhar on Feb 10 2023, 2:11 PM.

Details

Summary

This enables us to use the common fold helpers on elementwise ops that
produce different result type than operand types, e.g., arith.cmpi or
arith.addui_extended.

Use the updated helper to teach arith.cmpi to fold constant vectors.

Diff Detail

Event Timeline

kuhar created this revision.Feb 10 2023, 2:11 PM
kuhar requested review of this revision.Feb 10 2023, 2:11 PM
kuhar updated this revision to Diff 496600.Feb 10 2023, 2:12 PM

Drop accidental includes

Mogball accepted this revision.Feb 13 2023, 8:54 AM
This revision is now accepted and ready to land.Feb 13 2023, 8:54 AM
Mogball added inline comments.Feb 13 2023, 8:55 AM
mlir/lib/Dialect/Arith/IR/ArithOps.cpp
120

please make this change everywhere else too

kuhar added inline comments.Feb 13 2023, 9:00 AM
mlir/lib/Dialect/Arith/IR/ArithOps.cpp
120

Why? The method version seems much more popular in mlir. Is there consensus on this or some past discussion?

Mogball added inline comments.Feb 13 2023, 9:56 AM
mlir/lib/Dialect/Arith/IR/ArithOps.cpp
120

See https://discourse.llvm.org/t/updates-to-casting-h/62392

Most of the MLIR code has not been refactored to use the preferred style.

kuhar marked an inline comment as done.Feb 13 2023, 11:01 AM
kuhar added inline comments.
mlir/lib/Dialect/Arith/IR/ArithOps.cpp
120

I understand there are some historical reasons why MLIR started with casts as methods and that the free function casts are available, but I'm not aware of any wider preference for free function casts in MLIR. I started a thread on discourse to clarify this: https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443.

Would you mind if I left this as-is for consistency with the existing code, and change to free functions once it's clear there's consensus on this in the community?

This revision was automatically updated to reflect the committed changes.
kuhar marked an inline comment as done.