Commit 0301bf9
authored
`math.powf(x, y)` never really supported negative values of `x`, but
that was unclear (happened to work for some values of `y`) until
llvm#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: iree-org/iree#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 <[email protected]>
1 parent 48c92dd commit 0301bf9
File tree
2 files changed
+20
-4
lines changed- mlir
- lib/Dialect/Math/Transforms
- test/Dialect/Math
2 files changed
+20
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
328 | 331 | | |
329 | 332 | | |
330 | 333 | | |
| |||
358 | 361 | | |
359 | 362 | | |
360 | 363 | | |
361 | | - | |
362 | | - | |
| 364 | + | |
363 | 365 | | |
364 | 366 | | |
365 | 367 | | |
366 | 368 | | |
367 | | - | |
368 | 369 | | |
369 | 370 | | |
370 | | - | |
| 371 | + | |
371 | 372 | | |
372 | 373 | | |
373 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
374 | 379 | | |
375 | 380 | | |
376 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
288 | 299 | | |
289 | 300 | | |
290 | 301 | | |
| |||
0 commit comments