[llvm] [InstCombine] optimize powi(X,Y) * X with Ofast (PR #69998)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 01:00:57 PDT 2023


https://github.com/nikic commented:

We have three variants of this optimization now: `powi(x,a)*powi(x,b) => powi(x,a+b)`, `powi(x,a)/x => powi(x,a-1)` and `powi(x,a)*x => powi(x,a+1)`.

I'd suggest to move most of the transform into a helper function, that will accept `x, a, b`, `x, a, -1` and `x, a, 1` in the above cases and then do the common checks and transform.

This will also fix the bug in the current `powi * powi` transform, which fails to perform the necessary overflow check.

https://github.com/llvm/llvm-project/pull/69998


More information about the llvm-commits mailing list