This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Arithmetic] Add common constant folder function for type cast ops.
ClosedPublic

Authored by jacquesguan on Apr 11 2022, 2:26 AM.

Details

Summary

This revision replaces current type cast constant folder with a new common type cast constant folder function template.
It will cover all former folder and support fold the constant splat and vector.

Diff Detail

Event Timeline

jacquesguan created this revision.Apr 11 2022, 2:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 2:26 AM
jacquesguan requested review of this revision.Apr 11 2022, 2:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 2:26 AM

Could you please add a longer commit description that motivates this change? From what I can see, it replaces a small amount of boilerplate with a longer and complex utility function; not sure if the trade off is the right one here.

mlir/include/mlir/Dialect/CommonFolders.h
117

Nit: either const & or &&.

118
140

Nit: no else after return.

Could you please add a longer commit description that motivates this change? From what I can see, it replaces a small amount of boilerplate with a longer and complex utility function; not sure if the trade off is the right one here.

OK, after the replacing, we could fold constant splat and contant vector, not only the constant integer or float.

ftynse requested changes to this revision.Apr 12 2022, 12:51 AM

Then please (1) update the commit/diff description accordingly (the short version better highlight the added functionality, and the long version should explain why the change is made) and (2) add tests that exercise the vector versions.

This revision now requires changes to proceed.Apr 12 2022, 12:51 AM

Address comment.

jacquesguan edited the summary of this revision. (Show Details)Apr 12 2022, 5:43 AM

Then please (1) update the commit/diff description accordingly (the short version better highlight the added functionality, and the long version should explain why the change is made) and (2) add tests that exercise the vector versions.

Done, thanks.

ftynse accepted this revision.Apr 12 2022, 5:49 AM
This revision is now accepted and ready to land.Apr 12 2022, 5:49 AM
This revision was landed with ongoing or failed builds.Apr 12 2022, 7:12 PM
This revision was automatically updated to reflect the committed changes.