Fix handling of special and large vals in expand pattern for `round`
authorRamiro Leal-Cavazos <ramiroleal050@gmail.com>
Thu, 20 Apr 2023 18:00:08 +0000 (18:00 +0000)
committerRobert Suderman <suderman@google.com>
Thu, 20 Apr 2023 18:08:19 +0000 (18:08 +0000)
commitab2fc9521ec606603412645d4a4b3cf456acd153
tree709b083f0984cb9d7b178c7c2dca5c8474715132
parentbbc983d33a17b87012c18053a816a8984ab191ca
Fix handling of special and large vals in expand pattern for `round`

The current expand pattern for `math.round` does not handle the
special values -0.0, +-inf, and +-nan correctly. It also does not
properly handle values with magnitude |x| >= 2^23. Lastly, the pattern
generates invalid IR when the input to `math.round` is a vector. This
patch fixes these issues.

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D148398
mlir/lib/Dialect/Math/Transforms/ExpandPatterns.cpp
mlir/test/Dialect/Math/expand-math.mlir
mlir/test/mlir-cpu-runner/test-expand-math-approx.mlir