[llvm] LoopIdiomRecognize: detect and convert powi idiom (PR #72650)

Joshua Cranmer via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 17 14:39:08 PST 2023


jcranmer-intel wrote:

I'm skeptical of this change for quite a few reasons:

- `powi` corresponds to a GCC builtin that is only defined for C int (which is `i32` for most targets).
- `powi` isn't always lowered by targets correctly for non-`i32` parameters. Several targets fail to compile `llvm.powi.f32.i16`, for example.
- Unlike `memcpy` and `memset`, which tend to be important enough internal intrinsics that you have to handle them correctly even in freestanding modes, `powi` is... not that. Without having a way to forcibly disable the optimizer from trying to generate `powi`, I don't think this patch can even be contemplated.
- Checking for `fast` rather than appropriate individual fast-math flags is weird.
- This transform is only beneficial if the result of the multiply is *only* used outside of the loop. `replaceUsesOutsideBlock` doesn't guarantee that.
- I'm somewhat skeptical that this is going to be a useful optimization in practice. I don't see the kind of loops where this transformation would be beneficial just coming up all that frequently, even as something that might be the result of optimization.

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


More information about the llvm-commits mailing list