This is an archive of the discontinued LLVM Phabricator instance.

[mlir][math] Expand math.floorf to truncate, compares and increments
ClosedPublic

Authored by bviyer on Apr 10 2023, 12:52 PM.

Details

Summary

Floorf are pushed directly to libm. This is problematic for
situations where libm is not available. This patch will break down
a floorf function to truncate followed by an increment for negative
values, if necessary.

Diff Detail

Event Timeline

bviyer created this revision.Apr 10 2023, 12:52 PM
bviyer requested review of this revision.Apr 10 2023, 12:52 PM
rsuderman added inline comments.Apr 10 2023, 1:07 PM
mlir/lib/Dialect/Math/Transforms/ExpandPatterns.cpp
192

Missing a newline at the end of the file.

mlir/test/Dialect/Math/expand-math.mlir
140

For CHECK statements we typically do the following

CHECK-DAG for any constant values (e.g. arith.constant)
CHECK: for any computation.

In theory you can also do CHECK-DAG for everything but the return checker.

150

Missing a new line at the end of the file.

mlir/test/mlir-cpu-runner/math-polynomial-approx.mlir
626

Could you include boundary checks for both positive and negative values? E.g. -2.0 and 2,0.

bviyer updated this revision to Diff 512246.Apr 10 2023, 1:58 PM
bviyer marked 4 inline comments as done.

Fixed all the changes requested by rsuderman.

rsuderman accepted this revision.Apr 10 2023, 2:01 PM
This revision is now accepted and ready to land.Apr 10 2023, 2:01 PM
This revision was landed with ongoing or failed builds.Apr 10 2023, 2:09 PM
This revision was automatically updated to reflect the committed changes.