This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Tosa] Fix fp canonicalization for `clamp`
ClosedPublic

Authored by rikhuijzer on Jun 4 2023, 11:09 PM.

Details

Summary

The canonicalization for clamp removed the clamp operation when the
chosen min and max values were outside the range of what is possible to
represent with the input type. For example, if the input type is i8,
then the min and max values must be between -128 and 127. If the min and
max are, say, -200 and 200, then the clamp operation can be safely
removed.

However, as pointed out by @wyanzhao, this is wrong for floating point
types since they can represent infinity.

Fixes #62341.

Diff Detail

Event Timeline

rikhuijzer created this revision.Jun 4 2023, 11:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2023, 11:09 PM
rikhuijzer requested review of this revision.Jun 4 2023, 11:09 PM
jpienaar accepted this revision.Jun 5 2023, 7:24 AM
This revision is now accepted and ready to land.Jun 5 2023, 7:24 AM
This revision was automatically updated to reflect the committed changes.