llvm-project
0301bf97 - [MLIR] Lower `math.powf(x, 3.0)` to `x * x * x`. (#127256)

Commit
227 days ago
[MLIR] Lower `math.powf(x, 3.0)` to `x * x * x`. (#127256) `math.powf(x, y)` never really supported negative values of `x`, but that was unclear (happened to work for some values of `y`) until https://github.com/llvm/llvm-project/pull/126338 was merged yesterday and lowered it to the usual `exp(y * log(x))` outside of a few special exponent values, such as y == 2.0` lowering to `x * x`. It turns out that code in the wild has been relying on `math.powf(x, y)` with negative `x` for some integral values of `y` for which a lowering to muls was intended: https://github.com/iree-org/iree/issues/19996 This PR adds such a lowering for `y == 3.0`. It "fixes" such cases, and it is a more efficient lowering anyway. There needs to be a wider project to stop altogether using `powf` with negative `x`, use `math.fpowi` for that. Signed-off-by: Benoit Jacob <jacob.benoit.1@gmail.com>
Author
Parents
Loading